On 15 May 2023 14:07:31 BST, Lydia de Jongh <flexj...@gmail.com> wrote:
>> ...
>> #[SomeAttribute(callback: nameof(\Acme\bar(...))]
>> ...
>
>This callback to nameof()..... is really terrible  😣😣

Just to be clear, the "callback:" in that example is existing syntax for named 
parameters, not part of the nameof() syntax. A positional parameter would just 
look like this:

#[SomeAttribute(nameof(\Acme\bar(...))]

That's the same number of characters as this:

#[SomeAttribute(\Acme\bar(...)::nameof]

The main difference is the the function-ish syntax makes it a bit clearer what 
you're asking for the name of, because the whole thing is in parentheses. There 
might even be cases where the function-ish syntax needs additional parentheses 
anyway, like are needed in (new Something)->doSomething()

Changing "nameof" to "function", "method", etc depending on type doesn't really 
add anything, since the output is always a string anyway, not some 
type-specific thing.

Regards,

-- 
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to