Re: Brainstorming: quoted identifier operator

[email protected] (Branislav Zahradník)
Newsgroups perl.perl5.porters
Message-ID <CAB=rbO=tyUZ9zsqA58XpwY6GhXu5FjDuDY5vFojqOxCH9UH4Bw@mail.gmail.com>
On Wed, 7 Jan 2026 at 12:44, Philippe Bruhat (BooK) <[email protected]>
wrote:

> On Wed, Jan 07, 2026 at 12:22:47PM +0100, Christian Walde wrote:
> > On 07/01/2026 12:16, Dave Mitchell wrote:
> > > On Wed, Jan 07, 2026 at 10:56:03AM +0100, Branislav Zahradník wrote:
> > > > just another idea based on my everyday work - let's defined new
> quoting
> > > > operator: quoted identifier.
> > > ...
> > >
> > > You don't say what this quoting operator actually does.
> >
> > The proposed example is:
> >
> > sub qi (this is nicely readable test name) {}
> >
> > This tells me the intent is to be able to declare sub names similar to
> how
> > prototypes are handled, i.e. with literally anything in them.
>

Yes, anything (though primary usage is for use case where current
identifier is transformation of real text - to avoid code duplication)


>
> How would the sub be invoked, though?
>
> Like this?
>
>   qi(this is nicely readable test name)( @args )
>

Yes, qi() will act as as single token (bareword).


>
> Surely not this, right?
>
>   qi(this is nicely readable test name)->( @args )
>

Of course, this will remain as it is - invoke coderef returned by function


>
> We already have syntax for declaring and calling subs with unusual names:
>
>     no strict 'refs';
>     *{"some readable name"} = sub { say "foo" };
>     &{"some readable name"}();
>
> The fact it doesn't look so great might actually be a good thing...
>

As I tried to mentioned (if I failed I'm sorry), I can see effective usage
only integration
scenarios, where primary identifier of behaviour is a string
(non-identifier).

what I can imagine, is for example introduction of new prototype I
(identifier), and capability to
declare for example:
subtest (i&)

so one will be able to write:
subtest qi (validation errors) {
}

(but that is for future, I don't have vision yet how to implement this)


> Identifiers are everywhere, including variables, does that mean we could
> do this?
>
>   $qi(my favorite variables have long, descriptive names)
>

I didn't think about this (part of brainstorming is pointing it out).

For sigil symbols I'd restrict such usage to braces syntax: ${ qi (my
variable) }.


>
> Also, as far as I know, the only variables names that do not have to be
> proper identifiers are package variables (because of the way packages
> work), no? Which means this wouldn't work for lexical variables.
>

As you mentioned packages: consistent implementation will (in my eyes) may
lead to change of treating
namespaces in Perl core. For example:
Foo::qi (bar::baz) is for me different package than Foo::qi (bar)::baz

I'm already experimenting with usage of pad to replace GV
(based on my older PR replacing sigils in pad with symbol identifier, with
new symbol identifier "namespace")


>
> Also, would qi interpolate?
>
> --
>  Philippe Bruhat (BooK)
>
>  People are all unique- but some are more unique than others.
>                                     (Moral from Groo The Wanderer #22
> (Epic))
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.