Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124748 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id EEB7D1A00B7 for ; Sun, 4 Aug 2024 18:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722795939; bh=15OETxDJxfg+XK/A5RKhmKBbH/bsAhi+q5OJLl+BPrc=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Y/ng+r91N5OTSg25BUOUyrePLbEVAYf0VpWPi30SMlb//+QLMaCud+FQwoR0f+m0C 9WGONwvo6o5FMQe4n1lkaK/1F9bZk1n9lxMs3AkPI2T6z4WFGkS7YH+3BdBwLbPrDl p8PnkJkH8xS4OJxhAecq23CFwBWVKf1rBzv4DLVrU3n7I9K8iOg6WpfW6p+kyWLa2F bYOA1hT6Crej3McrnoubePOyZLlvllwdfAMZhq1xVYoihXfOmwlUGQUP5rrOFHl04+ phpnAY1SSWLTtkUYy2lym80sebnz/gcbES1SVYhs7nMDqUhRjxGZIBi9hBofd3EYzX 2scCt+zj7+ORg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B79BB18006F for ; Sun, 4 Aug 2024 18:25:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 4 Aug 2024 18:25:38 +0000 (UTC) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-428ec6c190eso14883075e9.1 for ; Sun, 04 Aug 2024 11:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722795836; x=1723400636; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=MXvqnU+++SkJno4MHtKPGXj/XIcmFYO5uPS6UVtCGgE=; b=I8pHmXPtCEwEvBV/m9QteN48CwGiOTv2VD/6PmVQWavCYDBX+k+ismB1KZTHIlBCF0 H7xZjimIsZaxXuRKddqYAuDj5H4Hvx8Zdf12I3wMBLCwrk306HpVNdB46xTfuhpKSo7G JHp6UTQMBVKuFNt3aE+q9Pee8D8JySbTtUqaJmYJOBdSAYl9vFse+mikSaQJjcf6DzP+ 4zcRbpTlelLww6RQ+zmZjwVqifzbIU2Btp4KzXnZK+COlrDz6AKqTwECbQqa5yGkDCW+ i7XIxl/AlxJPwuRQCEgY6nT0DtKIUodOoCB0Ip1pOjqKx9yzDDhytNhyliSw9bTLbiuI ICdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722795836; x=1723400636; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MXvqnU+++SkJno4MHtKPGXj/XIcmFYO5uPS6UVtCGgE=; b=h9/SMFiQaNc3S5ua3pwvn42qrA+b9OsYwtZnHvH8tSrCaV7GNOT3Sc4Ixoz0V8mJoK 05vpBzdJbEuZvg85+I8xwcrNCvoNrSdqJZ5+Sm+h9TXwksECf+mUMKpjDvmt1FG/Xwvp 4iOFCpB4OfhtFJoOSKpW8lCZXWxwk/90/wNhmw6/+QecNK7HeF3I1Mx+NLMkK65zFPLk dfLfLZ+MLYOU54bMzi6J7b/xUhERaeaPZz25mMuqSCFhjwih4sywHntzNGcAeyntBJ2d bzgW1Z0qYVmUn9wyIhVG2twLLW+HjlAP6VY66qqC/EJ7EsOmKd3pJu/rJt0tzF0T63sp FT/g== X-Gm-Message-State: AOJu0YxPgbACJxyk9k85hDWOcT4G3tUJ+o3zvlLRZaAl1yFoPT/QkMqa x+CvAAuu3cgfSYZln9R23oWLfHb2t8z9J79JO8hpVNySnUUc1IooDiPTOpj6 X-Google-Smtp-Source: AGHT+IGF71SXuS6WC5SHiy3dCeijWN6LUcFrMiCeh2YAxnpEIMp45/DTG0yc1x+CspbODnLw0wqB1w== X-Received: by 2002:a05:600c:3b9b:b0:426:5f8f:51a4 with SMTP id 5b1f17b1804b1-428e6af4d9fmr58933175e9.12.1722795836061; Sun, 04 Aug 2024 11:23:56 -0700 (PDT) Received: from [192.168.0.104] (178-117-134-240.access.telenet.be. [178.117.134.240]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-428e6e3174bsm108772615e9.21.2024.08.04.11.23.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 Aug 2024 11:23:55 -0700 (PDT) Message-ID: <803741ef-7b51-4a92-8368-41e47f7783ab@gmail.com> Date: Sun, 4 Aug 2024 20:25:09 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Add Directive to Make All Namespaced Function Calls Global To: internals@lists.php.net References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: dossche.niels@gmail.com (Niels Dossche) On 04/08/2024 15:09, Nick Lockheart wrote: > Good morning all: > > When calling functions from the *global* namespace, the PHP parser > creates opcodes that use those functions directly. When those functions > are certain built-in functions, the parser can use special opcodes that > are optimized for those function calls. > > When calling functions from *within* a namespace, the parser does not > know at compile time if the function is defined in the current > namespace or if the global function will be used. > > Because unqualified function calls are ambiguous, the parser adds an NS > Lookup opcode which performs a runtime check for the function name in > the current namespace, and then falls back to the global namespace if > the function is not defined locally. > > This also prevents the parser from using dedicated opcodes for built-in > functions. > > This incurs a performance penalty. > > In the past, RFCs that aimed to address this issue got too hung up on a > syntax discussion, rather than a simple “should we solve this” question > proposed to the community. > > I would like to discuss and then vote on this proposal as a feature, > without getting into any specifics of syntax. > > I propose that we vote yes/no on if there should be some way, whatever > that way ends up being, to tell the parser to always treat unqualified > function names as global. > > I think it's important to get a “clean vote” on this issue, to separate > out if past objections were objections to the concept, or if only the > syntax proposed in past discussions was disfavored. > > To that end, I have created the following RFC: > > https://wiki.php.net/rfc/global_function_parser_directive > I am asking that we discuss and vote on the following question: > > “Should there be some way for developers to signal to the parser at > compile time that all unqualified function names found in a namespace > context are global, without a namespace lookup?” > > Yes: We should do this, let's discuss syntax possibilities. > > No: This should not be a feature at all. > > Thank you for your consideration. Hi Nick I'm not sure how I feel about adding an additional signaling / syntax system to signal the parser to change the behaviour of function lookup. It means people have to take into account that a fundamental behaviour can be changed. PHP is already hard to use IMHO because of many things you have to keep into the back of your head, and adding something like this adds even more complexity. If we're going to make such a change I'd rather have it unconfigurable. Kind regards Niels