develooper Front page | perl.perl5.porters | Postings from March 2021

Perl feature wish: my old dreams

Marc Chantreux
March 5, 2021 11:29
Perl feature wish: my old dreams
Message ID:

Le Fri, Mar 05, 2021 at 09:05:34AM +0000, Konovalov, Vadim a écrit :
> > > It would be handy to have a "quote word arrayref operator" in Perl, 
> > > that combines [] with qw.

months after perl 5.10 was released, french perl mongers and i  had a
chat (i gave a lightning talk?) about things i wanted in new perl
versions (we had a pumpkin back in those days). some people from p5p
explained to me that it would leads to much code in the interpreter.

But maybe it would be eaiser nowadays so i come out with the ones i

* method calls without parrentheses

    $foo -> $this, $list, $of, $argument ;

   so method call could be like an operator and the parentheses
   can appear in the right positions in a chaining for example

    ($foo -> $call, $foo, $method) -> $second, $call

* a XS (even better: core) version of the concept behind perlude:
  having keywords to compose iterators from existing operators.

    my $g = sub { <$e> // () };
    my $f = sub { print if /gold/  };
    my @r;
    while (@a = $g->() ) { push @r, grep $f->(), @a }

    should looks like

    now {print if /gold/} <$e>

    with perlude, i can write

    now {say} take 5, filter { -s && /\.txt$/ } sub { <*> // () }

    to print the 5 first text files with content (and the generator
    isn't totally consumed).

    but it has the same problem OO frameworks have: could be much faster as perl built-in

* the & signature to take a ref as well

    now (&$) { ... }
    now {$code->()} $a ; # ok
    now $code, $a; # error :)

* fix the context bug in the <> operator so people can use <$obj>
  instead of $obj->next
  the idea behind it was to have an obvious way to iterate so
  libs like perlude won't have to deal with many method names

  i don't use perl that much nowadays but what i believe is:
  * the problem is fixed
  * but no one overload <>

  which saddens me because

* the switch to actually return values the way if block does
  (but switch was deprecated.)

* a new q* management q[intepolation?][ref] so

    operator type     interpols ref
    qs       string   n         n
    qss      string   y         n
    qS       string   n         y
    qSS      string   y         y
    qw       list     n         n
    qww      list     y         n
    qW       list     n         y
    qWW      list     n         y
    qH       list     n         y (hash ref)
    qHH      list     y         y (hash ref)

    i talked about the ruby % wich looks better than q and reserves less

* a for that can take any numbers of arguments (the way modern shells do
  and raku do). i

    for $x, $y ( map split, @lines ) {


marc Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About