Re: Brainstorming: quoted identifier operator

[email protected] (Branislav Zahradník)
Newsgroups perl.perl5.porters
Message-ID <CAB=rbO=3WTVhkVnHNgHtadDyd2baHmQvEn0RsnXK5Y8g=L1aVA@mail.gmail.com>
On Thu, 8 Jan 2026 at 13:09, Aristotle Pagaltzis via perl5-porters <
[email protected]> wrote:

> * Branislav Zahradník <[email protected]> [2026-01-07 11:06]:
> > ```
> > sub qi (this is nicely readable test name) {
> > }
> > ```
>
> If you really want this,
>
>     *{'this is nicely readable test name'} = sub { say "hi" };
>     &{'this is nicely readable test name'};
>     __END__
>     Output:
>     hi
>
> The fact that it is kinda ugly is IMO a feature. I don’t think heavy use
> of this should be encouraged. And I actually find it more readable. IMO
> it is much quicker to skim this:
>
>     &{'recursive fibonacci'}($n - 1) + &{'recursive fibonacci'}($n - 2)
>
> … than this:
>
>     qi(recursive fibonacci)($n - 1) + qi(recursive fibonacci)($n - 2)
>
>
this usage is on the edge of common sense even for me.

My intention raised from my fields of interest - testing, web services, SQL:

- test framework (like Test::Class): sub qi (this test case shouldn't
create entity) { }

- ws framework: sub qi (/user/:user_id) { }

- data structure (xml, json) data->function mapping:
  package Foo { sub qi (user-name) { process user name } }

  for my $key (keys %data) {
    next unless Foo::->can ($key);
    ..
  }

- integration (SQL, other programming language): for example, 1:1 mapping
of Oracle DB to Perl:
  select [
     qi (v$session)->username,
 ]

As always, when there is something to use, someone will abuse it.
What is abuse for one person, maybe on other hand perfect domain specific
use for another person.

Should these quoted identifiers be different from barewords with same name,
it will be even easier
to build simple DSL:

sub qi (not) { }

(though even now one can create for example "my sub if { }", completely
screw syntax in scope where it is valid)

As I see it, this feature will simplify integration with outside domains.
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.