Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125074 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 807391A00BD for ; Tue, 20 Aug 2024 17:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724173601; bh=Sc7eNON93sCDJvRNsST7Sai2ahlaQtJ1BOT9ndU4dPo=; h=References:In-Reply-To:From:Date:Subject:To:From; b=la7IJVGpWmZegDIhzWGtVfIQ+PR7GVlDIhKLZr0SNYE3t8A2qhBMTW1Hh9ZlpoXT1 Vq5jUuyq21TyRrYQ1/DNJdzjbmh6MB5XYBQDlErdd7fSMa4AziYvMwqcmrKS6JbrZm zPYjMWgLJx+fR8QCRTEfM7bU3ij3CdjdTYpL48fm/5rR2xYfXQGInAeJdsElfscj5l RO1isYQ4BLpA6aGY72mx9LV62L8Rjhe6sCYa8wMWB7ov7t5WopvBaamiqnmaM7d2Xz y2kCPrsEHz8TZpuu9gWMX7swG6JtTAkIhTssYgFrzqeYn33vVrx12PQQJR4/ymWHiE TrUTUV3g4Oocw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 20FF118006F for ; Tue, 20 Aug 2024 17:06:41 +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-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (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 ; Tue, 20 Aug 2024 17:06:40 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6bf6606363fso33169076d6.3 for ; Tue, 20 Aug 2024 10:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724173490; x=1724778290; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bOuFAc6WknruT/C2F5VK2evuvYTyK9GxdL7sFAcUMbs=; b=exvOowid08N0tavlTp/8Knmrx8N4jHhsHYN/T/NDJ8eq9+laGFaUzgjUNMDM5zdqTo oDmWp+xgtlD8E19nS+QbTJdqG6wPokeahO4nikkLqTY/Rm7xa5tOZ8K9IaiIF3BBmZkU 5fxr8yaIITTPKrYPHKAhMiGh9/jQLFWLS9kNLDEFo2b/6FNX20eMy5mH7U9CHwWvYP59 YHr0R8GT6bJISaWlqifzviQMi1aXxqW3r9gfja4OyqFnGQgO6z7s+Usml+rZC0R12N9v Ibu+vj7Sipc9Ml2lYppgbUDkTzVvqX+rPDPJbLG5AfsfNxiVlPqqs1Y5RB074T7qp8xd V1MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724173490; x=1724778290; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bOuFAc6WknruT/C2F5VK2evuvYTyK9GxdL7sFAcUMbs=; b=FOdpooXsHS9mlV2hB9B6d2PuVIMly0nOHXIus/lqDFIFVLf3LZujzJstn9l2g0xUua 8wFDBdx85BDuvtoPDmHV1F31mVNsaFbJKIYpaabYR6bRnlcgtiEt4Z5B2S2XUowMsFN+ 2rKFn0pqXn7Omf97e/+33TQ7rDfUmjaL7tlxPlt5azYgZNRXZC5kzXfxdjjGHchezODi i3r/WETLuqZ8Ww6o6505mMa96nEp6SjSrqijCkUFJdlvXwYshopXvVVs5JxASuceRqMu InwFwvb0IIeQjfRBkkky0y0mAGzZopiExHcz/2+cGIk4OH1YheKLAfF+5qQVWiRKBUM0 AkKA== X-Gm-Message-State: AOJu0YzbcHwyVyyj4V7JiSLU0EXYdfmCp3HPQLXGML4zEF1kvh2RFJlz GUG5xilbgeZVxpO2HA9j6l+5VyaENnKUaxi9jllU/b1OvtHJo4JGdBIg7zXtQaNVmToo93EUUNM UNQ/77KgOGQiKlH58emJv7xiwyQhxN5Su7Yk= X-Google-Smtp-Source: AGHT+IG+YQrPOFeo+Zul69dUkX7ELQVwR3uebaWV/AIaDNJLuktA+ZXDdUGR2gyxZ/xkrYRwVO02FGILAmDyYXaSJYg= X-Received: by 2002:a0c:e408:0:b0:6bf:7d33:342c with SMTP id 6a1803df08f44-6bf7d333561mr141604576d6.1.1724173490282; Tue, 20 Aug 2024 10:04:50 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 20 Aug 2024 19:04:39 +0200 Message-ID: Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Levi On Tue, Aug 20, 2024 at 5:14=E2=80=AFPM Levi Morrison wrote: > > I have long been in favor of a larger BC break with better language > consistency. Class lookup and function lookup with respect to > namespaces should be treated the same. The difficulty is getting a > majority of people to vote yes for this. Keep in mind that qualifying > every global function is annoying but probably can be somewhat > automated, and will bring better performance. So again, this improves > the existing code even without upgrading. > > Yes, there would be complaints about it. Yes, there are probably some > people or projects who wouldn't upgrade. I don't particularly care, as > there are increasingly more operating systems and companies providing > LTS support for long periods of time. Probably Zend.com will offer LTS > support for the last PHP 8.X release, and possibly there will be some > distro which also has it. I believe it's the right thing to do > because: > > 1. It's faster. > 2. It enables function autoloading in a similar manner to class autoload= ing. > 3. It's more consistent, and simpler to teach and maintain. > > It's rare that you get all of these together, often you have to make > tradeoffs within them. The approach I originally proposed also solves 1. and 2. (mostly) with very little backwards incompatibility. Consistency is absolutely something to strive for, but not at the cost of breaking most PHP code. To clarify on 2.: The main issue with function autoloading today is that the engine needs to trigger the autoloader for every unqualified call to global functions, given that the autoloader might declare the function in local scope. As most unqualified calls are global calls, this adds a huge amount of overhead. Gina solved this in part by aliasing the local function to the global one after the first lookup. However, that still means that the autoloader will trigger for every new namespace the function is called in, and will also pollute the function table. Reversing the lookup order once again avoids local lookup when calling global functions in local scope, which also means dodging the autoloader. The caveat is that calling local functions in local scope triggers the autoloader on first encounter, but at least it can be marked as undeclared in the symbol table once, instead of in every namespace, which also means triggering the autoloader only once. Ilija