in reply to Re^3: Half-serious quest for prefix anonymous refs taking
in thread Half-serious quest for prefix anonymous refs taking

The prototypes allow you to skip your parentheses, which makes the sub act more like a built-in. Since you said you wanted a built-in, I thought I'd fake it as well as can be done.

I personally believe you'll find that you don't need prototypes at all, to allow one to skip parens:

C:\temp>cat mkaref.pl #!/usr/bin/perl use strict; use warnings; use Data::Dumper; sub mkaref { [@_] } print Dumper mkaref qw<foo bar baz>; __END__ C:\temp>mkaref.pl $VAR1 = [ 'foo', 'bar', 'baz' ];

However I did hope it was clear enough that my "quest" is not for builtin (looking) functions, because in that case I can write them myself full well, but for builtin (hypothetical) syntax.

--
If you can't understand the incipit, then please check the IPB Campaign.

Replies are listed 'Best First'.
Re^5: Half-serious quest for prefix anonymous refs taking
by TGI (Parson) on May 30, 2008 at 21:42 UTC

    You are absolutely right about the protoypes. D'oh. It's not the first time I've made a fool of myself.

    Prototyping built-ins with modules seems to be the thing to do in Perl. Look at the history of say(). Building your proposed changes and then advocating them seems to be the way to go.


    Update: Uh, ambiguous use of the word "protoyping" on my part. In paragraph one, I meant the Perl language feature. In paragraph two, I meant the act of making a test version of something.

    I agree with you about prototypes (the perl feature). They are so useful that in 8 years of using Perl, I've used them in actual working code 2 times. (Unless you count my newbie error of trying to prototype everything--then the count gets a bit higher. :) )

    If you want to advocate for this sort of built-in, build a library version of it that acts as much like you want the built in to work, and push it. If it becomes popular enough, the P5P/Perl6 crowd may decide that the deliciousness of it is irresistible and incorporate it. We now have a switch and also 'say'.


    TGI says moo

      I personally believe that the only useful prototypes (for me) are \@, then possibly \% although I can't remember having ever used it, and &. Oh, and the empty one: ().

      --
      If you can't understand the incipit, then please check the IPB Campaign.