Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119909 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65995 invoked from network); 11 Apr 2023 11:45:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Apr 2023 11:45:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7324C18054C for ; Tue, 11 Apr 2023 04:45:51 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Apr 2023 04:45:51 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id v29so7257328wra.13 for ; Tue, 11 Apr 2023 04:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681213550; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=eNcJdI5oXXRWmJWKjt/7VjMS0ff4minZBISxSVO13tQ=; b=fubjcewekssXCq9B0WA11o8PPstQP6hYRQMLdiC1PBz+tq5Ok60fcPu98ftXg/pJkl TiPtrm5p5uArrSNYCY26oAJbA35LdXqKWxSxPYpk2a4DDDG8TlRALxQFxApGweHLH2hr H2x0djIJhbnj33j5CtJc9qhspLFk0r5bgMhNpYfJ6YmRL+ySmbcwrrovEg3WPlLxhfVH UX3OBnIPy/fbBo/BwqADw2p4K1YLS83aMiO4ChytZZzd3pzQgLB+BLyh7U57NCQQAMAP BxhWp/SDbpkrpCy0/zT5NGaax/XVQ+J4nE+dQVWFshmXJI9IG1W1r8eh4DGvEBdDLfLz kB3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681213550; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eNcJdI5oXXRWmJWKjt/7VjMS0ff4minZBISxSVO13tQ=; b=6lHZJ2JrgZVohWWObRLLeLi1fYoxm5gY8ZESl8uR1Q/86/Yyo4Rz7vDiwm2Fwbg7uV 4sffimtQKoCwCVTF35xzsPvCwqVjSeU8AHCac93Bibbv3Vi1yBixzGAtwF5/Y2wwnoLB vejpTK+ePnjdGLYNrv6d1JWry4HizaAwyMeCS1PIVsfUdZoGAJSBSMsT5fNVxMLIwqBy pkGm/gxrAB5l3scmaNch8LGB5Q7NZb21bD2sEXmNxeIaddqLIZx4YikSiMbi9UzU1E01 MBisHcxdI7c+qZ1bvWkMIpU33rAtXLcRmsfjgZLojMZxx781I+8Lx0FNtBdqJnE9ipAN odSA== X-Gm-Message-State: AAQBX9cD1BayTjiwliTN9wCP7bA75n5fknoPF81A4lSBM34xJZqg7Sr4 I5b5Hfus8TbF8XouK0fo1IQ= X-Google-Smtp-Source: AKy350aDMePrHz2s2kgX6Qw+QXNrSLcj0vnJyPhz4axztIuyYjTE8hkkWr2K2pWY0QMNIDqHhEnmRA== X-Received: by 2002:adf:fd0f:0:b0:2cf:e0bc:9639 with SMTP id e15-20020adffd0f000000b002cfe0bc9639mr9495158wrr.37.1681213549628; Tue, 11 Apr 2023 04:45:49 -0700 (PDT) Received: from [127.0.0.1] (cpc83311-brig21-2-0-cust191.3-3.cable.virginm.net. [86.20.40.192]) by smtp.gmail.com with ESMTPSA id n11-20020adfe34b000000b002e5f3d81c06sm14451248wrj.89.2023.04.11.04.45.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 04:45:49 -0700 (PDT) Date: Tue, 11 Apr 2023 12:45:47 +0100 To: "G. P. B." CC: internals@lists.php.net User-Agent: K-9 Mail for Android In-Reply-To: References: <6FA5AA43-9738-4400-8D83-38FC2D464B82@gmail.com> Message-ID: <63FB2A01-481C-47B9-BD43-2BF29682F372@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: =?US-ASCII?Q?Re=3A_=5BPHP-DEV=5D_=5BRFC=5D_New_core_autoloading_mec?= =?US-ASCII?Q?hanism_with_support_for_function_autoloading?= From: rowan.collins@gmail.com (Rowan Tommins) On 11 April 2023 12:16:18 BST, "G=2E P=2E B=2E" wrote: > >However, we *already* do function pinning which can result in this >behaviour via the function cache, see the following bug which defines a n= ew >function via eval(): >https://bugs=2Ephp=2Enet/bug=2Ephp?id=3D64346 That's not the same thing - that's pinning *the meaning of an unprefixed n= ame within a particular scope*, my example was of using *a fully-qualified = function name*, of a function that has never been defined=2E Substituting a fully-qualified name in the example from that bug runs the = namespaced function just fine: https://3v4l=2Eorg/tReC3 >I am not sure that it calling the global strlen() is that surprising, as = it >is basically aliasing the function \Foo\strlen() to \strlen()=2E That's the implementation detail that I'm saying should not leak=2E It is = not the current semantics of function lookups, and I don't think it's desir= able semantics=2E >> Similarly, I think it should be possible to "unpin" a function lookup w= ith >> a later definition, even if no autoloading would be triggered=2E That i= s, >> this should not be a duplicate definition error: >> >> namespace Foo; >> if ( strlen('magic') !=3D 42 ) { >> function strlen($string) { /* =2E=2E=2E */ } >> } >> > >There are some larger technical issues at play, as mentioned in the >previous bug=2E The above code doesn't currently generate an error, and the function defin= ed is callable with and without prefix: https://3v4l=2Eorg/nPbat If I understand right, the caching issue is that some uses of unprefixed s= trlen(=2E=2E=2E) might not pick up the new function; but fully qualified us= es will reliably do so=2E=20 >That is actually interesting, hadn't thought about taking an array of >prefixes=2E >And yes, every callback call requires a VM re-entry, which is expensive= =2E > >Should the prefix be with or without the trailing backlash? It would probably make sense to follow Composer's lead and require it; the= ir reasoning seems sound (from https://getcomposer=2Eorg/doc/04-schema=2Emd= #psr-4): > Namespace prefixes must end in \\ to avoid conflicts between similar pre= fixes=2E For example Foo would match classes in the FooBar namespace so the= trailing backslashes solve the problem: Foo\\ and FooBar\\ are distinct=2E Regards, --=20 Rowan Tommins [IMSoP]