Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124742 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 53F881A00B7 for ; Sun, 4 Aug 2024 17:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722793390; bh=AK6LFev23GI8CzzbEqg8oehVLN2JcJRR1m/4ulxWa7Q=; h=References:In-Reply-To:From:Date:Subject:To:From; b=JWEAVkQPsp3IfB99igdkOSHVusMxW0Pm3e6duuXZ5W3bczpjtKZqjRv506ufHEWGY gI1TwQx3M3e8VuZeACAM6RcVW1+DEEqs6JnrvFCosmqrBgdomFdB0dsuMVSmgte4LZ V73I7yFp1trNOjCNCWy1ZLPp8nePFAm2SxT4yHXhl0+PsDykOlv7HrjnICsga23lx8 Zvzw1+I9JjjRNmKevRAR7EsvD+SXmoKmSd15/7fJc7IL+fjhmDQx5rTjxmRhEvUgoo tFhwWj741qfp/2OatJW6g2dZBiYn4QlXqw6Ut/EdAj02w72cleXysNx8l0djn+2Vhe 6d8jEmBXxtSXw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 14A4A180077 for ; Sun, 4 Aug 2024 17:43:10 +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 ; Sun, 4 Aug 2024 17:43:09 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6b797234b09so43162656d6.0 for ; Sun, 04 Aug 2024 10:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722793288; x=1723398088; 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=qdhWcYG16xcVJ+ebTkhcIJ/bUGnLX0cXHPGZyZwiZdo=; b=A143nKR5u77VVeovSYBZ+s+lPF5Yp+2wJHG74eDEnag3Dg0TtxvKRTlaiQb8vDq82B 1PHHXKuL8ZkFDs1P9Wmc/EsWFAA4HA7XMSdcyzvpOOu/wOazqjy/VOmGEzsr31JUIMeF ANl2yh5Mp5iZ8L/6mM8PHnQoRm/DwvWy5HY9QpsssJz+2KKGtvn9DrvoqwywnGdk4FEp WMbXlq2HDHgxdV9afe7JWXIn3WUnoXgxrphFrtbVFdMhYSd0PYPsU/OU4GqEivj33q/0 DU1Gpzn8FyGNDphsclCCEvwf3u/xtPA4MX9KdppsquOddl879Ffi5OfoUB2c9nsTFUdL BtPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722793288; x=1723398088; 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=qdhWcYG16xcVJ+ebTkhcIJ/bUGnLX0cXHPGZyZwiZdo=; b=YFjc2O7vz84vaqQ5vSDD56IreTiZVebIPY2Cp6r+5FVjhRmTuhxQAsLTzkk58daDPk hGtupuya3R1z9REYlhVAU1KrxP/3Wyz0K1nwkLPPmupdSN6KNAtuhlkTTI9wXHTeHZJH Ec7JfCFDDSKGuOUwDPMRhuYVbL5InhIUTIgcbemkU3atRDmLryat6PYMgJP17mVssB4d jXaCWFhNDx6/xlqUCcDJpzAi4YHo/MvFZeLQY9bqIefjsAp2QDttjCIptUx0N8Wdha5W nZSe8jRRcfJpfPWgUNs7Ikruffh5haMfp37UA/0aQCSlsGWYOg6k7mysPFm2HgURGLch 6Jew== X-Gm-Message-State: AOJu0Yyzu0Fa+pMRSbjVxaWzqSEORF/7lICKkR9FOtWmiF8fUGZrxtAN /Fx+czv3jdXVIsCjVfzrTjF4uQeAX3OC+frZmwy+5RHdZXOQvGIV1mOCvhYaRDN1uMkVofHXZKK 3yxLRhgIcBaAvyN46G0nBra2kucu2Y5tElSI= X-Google-Smtp-Source: AGHT+IGZBacEU/4XlbuPABgRO9Lwc/uICsgipA5tePoAtA7wcjXP8UgY6IZ2sJI08pl9DPdDt00ao/vAR2bJmITQ0VM= X-Received: by 2002:a0c:fca8:0:b0:6af:c2ec:3313 with SMTP id 6a1803df08f44-6bb91ea8049mr178647646d6.26.1722793288319; Sun, 04 Aug 2024 10:41:28 -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: Sun, 4 Aug 2024 19:41:17 +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 Rob On Fri, Aug 2, 2024 at 7:10=E2=80=AFPM Rob Landers wrot= e: > > So, what you=E2=80=99re saying is that symfony and laravel can get a perf= ormance increase by simply adding a \ in the right places? Why don=E2=80=99= t they do that instead of changing the language? Nothing, of course. However, a Symfony maintainer has expressed uninterest in prefixing all internal function calls, including automated use statements at the top of the file. Even if they did, most users will not. > For functions/classes in the same exact namespace, you don=E2=80=99t need= a use statement. But after this change, you do in certain cases? > > namespace Foo; > > function array_sum($bar) {} > > function baz($bar) { > return array_sum($bar); > } > > So, how do you use that function in the same file? Yes. But I'm not sure how that's different from today? If there's a local and global function declared with the same name, and you intend to call the global one, you'll already need to disambiguate the call with a \. With this change, your two options would be to: * Prefix your calls with namespace\. That's quite ugly, but is the syntax we currently offer. * Add a `use array_sum;` to the top of the file. An explicit use has upsides too. It makes it much more obvious that the global function is shadowed. > We can only see open source code when doing impact analysis. This means p= icking even a slightly =E2=80=9Cpopular=E2=80=9D name could go very poorly. Yes, and there are many more than 10 000 composer repositories. An impact analysis can give you an approximation for breakage, not absolute numbers. Ilija