Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120271 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69245 invoked from network); 14 May 2023 15:45:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 May 2023 15:45:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E1EE1180382 for ; Sun, 14 May 2023 08:45:23 -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_H3,RCVD_IN_MSPIKE_WL,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-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 ; Sun, 14 May 2023 08:45:23 -0700 (PDT) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6ab611e57c2so2893797a34.1 for ; Sun, 14 May 2023 08:45:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684079122; x=1686671122; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7g8tCOk8jZAXmA2H0ZBY7BK2dinN1abVBj6Qp6ENDXI=; b=cDcgBd65KRxuB5eUk7WWaXSHXTYU7DXOxdyBBZw++Vf9P4Q/QSW/En61O9V671x+Kj I0TIMn2wOEi4UiMQoe9khyvhiBm53Kl92isJRUh70qu2LXIe2Hc41UgC6sTlOSew5SfM aVvG1s1oxEb6j3SvI8RwrAWdN2anY8QS9at7sAXGZqGqVh6kzH7XLyZDev5Qx4ToBmpW E5vNpDk0PBv5Xpxa7roxYDS1vIXphcDctQfeqXaUQTtOZjDHmDd6tCK69fiDotMc9s1/ Mlx4wSLkZBhTrS0gwM4R7BB0giPZcimtq2MsiWZKUnSQdZzSTghQOuD7fDnHRC0J1sNz 23Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684079122; x=1686671122; h=content-transfer-encoding:cc: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=7g8tCOk8jZAXmA2H0ZBY7BK2dinN1abVBj6Qp6ENDXI=; b=QjZVg2qDTgf91TtDzkKy0EuJRcS5hKz2MFavHWNiSZnBu3v67S0BzuT4HQ+ln1p8xB mnxyKE22QrS5kO3qAiANqKTE5zBEZ6w2nz4K5PdeLuiQK0rc2lF9aVax32sCQNGyyBYM 7vDtPy6HKVc+f/iB2Z+IPPCY2jOOkJ52Ie21VhaQXgPaBHoR2+HfTQCnZI7GYwqfL6Yf 5EzlD1mJhHAAcMm4YNzYaQVMAykT98jOaMfN9IQ/0+12geYchp2PAkpKqoor3SQQtY4d np7aRVaws95STDTJ0fZiRb5Sb3uiFW0FdnO5KA2gd3QZ9iHuI3PnzGDBqGEd+CYdVNgM aRUQ== X-Gm-Message-State: AC+VfDxd/EOVmOcNf21g/dcQt/Sn3qab9eSCsnaXqJ6HBpa6twF7D7mh Zm2ybhJjmdUHqNwJfXeVAZY0WrD+kT0BKwFmXko1GBh6JBixFg== X-Google-Smtp-Source: ACHHUZ6sBe1+oLaaqJR5YECi/rh5uAYiAzs5lk9zHTJgW51KYTmQrEmYIzSiIjhzfE3kYESk62LTZTAT6lpvqwwx8kI= X-Received: by 2002:a05:6808:210e:b0:396:cd:82a1 with SMTP id r14-20020a056808210e00b0039600cd82a1mr881718oiw.19.1684079122550; Sun, 14 May 2023 08:45:22 -0700 (PDT) MIME-Version: 1.0 References: <436378BB-FDFA-43BD-A633-C030C347E683@gmail.com> <359D9C64-52A5-4BF5-91B5-72F7CE116F78@gmail.com> In-Reply-To: <359D9C64-52A5-4BF5-91B5-72F7CE116F78@gmail.com> Date: Sun, 14 May 2023 17:45:11 +0200 Message-ID: To: Rowan Tommins Cc: internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] [Discussion] nameof From: landers.robert@gmail.com (Robert Landers) > Conversely, namespace imports are entirely local to the current file (or = even a namespace{} block), and it's almost impossible for running code to s= ee anything other than the expanded name. > > That doesn't mean that there aren't good reasons to have nameof() handle = both things in the way proposed, I just think those reasons are probably di= fferent for the two cases. That's a fair point. Maybe it is worth putting it up for a secondary vote? I do have a strong preference, but I'd rather have full names than no names, and doesn't change the RFC that much. If I'm understanding correctly, it would only affect first-class callables and constants. > >> Can you give an example of such an error message that would want to ex= pose the local alias? > > > >Which error message helps in resolving the error and would be written > >by someone writing the code? > > To clear up any doubt, there was no sarcasm or aggression intended, I was= genuinely requesting an example, which you have provided, so thank you. FWIW, I didn't see it as a sarcastic question, but I'm a very sarcastic person IRL... so maybe I did and I just ignored it. =C2=AF\_ ()_/=C2=AF Either way, it was a good question. > This seems to be a common sentiment indeed - people prefer long lists of = "use function" to \ prefixes. It's not something I personally find unnatura= l, any more than "/images/logo.png" or "/etc/hosts", but I'm willing to con= cede I may be in a minority there. I've seen hundreds of lines of nothing but `use`... it's terrifying once you end up with a smattering of aliases thrown in, randomly, for good measure. I don't think you're in the minority for people who've been using PHP a long time -- or bitten by those files. As someone who's had to wade through those codebases, aliases matter a lot and I'd like to see them respected. I'm also realizing, as this discussion goes on, that there is precedent for the expansion via ::class, so maybe that is the right way to go after all? =F0=9F=A4=94 > The biggest weakness of a generic "nameof" is that it still doesn't hint = what kind of thing you want to mention. The 'kind' of the thing doesn't really matter, we just want the name of the thing. Basically, the string before `(...)`; the string after `->`,`::`, `$`, or in the case of constants, the string itself. > >IMHO, this comment isn't constructive or helpful, how can I help you > >understand? I'm more than happy to answer any and all questions, but > >comments like this are pretty demoralizing when there are only a few > >people discussing the feature in a community I'm relatively new to > > I'm genuinely sorry you felt this way, and it was absolutely not my inten= tion to criticise you. If anything, it was meant to be an admission of my o= wn failings, that I'd come into the discussion with the wrong preconception= s, because the use cases which immediately came into my head seemed to have= contrasting requirements from the ones that you intended. Thanks for explaining your intentions and no hard feelings from me. It can feel like an 'island of one' putting an RFC forward for the first time and a bit daunting when receiving negative feedback. Maybe there should be a 'buddy system' for first-time submissions that reach the discussion phase? A more experienced contributor could volunteer to help guide the person through the process, answer weird questions (like when is a secondary vote required or useful? I got some feedback that it was a bad idea to include one, but why? I'm sure there's some background there, but I'm in the dark with nobody to reach out to and ask for history lessons), give informal feedback, and someone to reach out to when you get stuck. > To put things into a more productive context, then, I think a useful impr= ovement to the RFC would be some examples of how you would use it with the = different supported types, showing why the proposed semantics are useful fo= r those scenarios. I can do that for sure. > On a different note, you've talked about how errors would be handled for = nonexistent constructs, but given PHP's dynamic nature, there's also a ques= tion of *when* they would need to exist. For instance, assuming we go with = Warnings, if I use nameof(Foo::bar), and class Foo is defined in a differen= t file, there's a few things that could happen: > > - the resolution happens while compiling a single file, in which case it = will always give a Warning, because any symbol outside the file is unknown > - the resolution happens at runtime, and causes class Foo to be autoloade= d > - the resolution happens at runtime but doesn't trigger autoloading, so w= hether it gives a Warning or not depends on whether other code happens to h= ave loaded the definition of Foo > - probably other options that I haven't considered > > With the "no error handling" version, this becomes moot, because it's jus= t a string manipulation exercise. That's how ::class currently works, apart= from a few specific cases like static::class and $someInstance::class I actually updated the RFC late last night with that information after some feedback from Dan. ;)