On Wednesday July 4 2012 1:27:27 PM Chris Nehren wrote: > On Wed, Jul 04, 2012 at 17:54:40 +0200 , demerphq wrote: > > On 4 July 2012 06:58, Chris Nehren <c.nehren/p5p@shadowcat.co.uk> wrote: > > > Recently I've been working on a DSL of sorts that would be more > > > succinctly expressed if I could have a prototype like ($&&). What would > > > break if we allowed the & prototype after the first position? To make > > > the proposed feature concrete, it would enable us to have syntax like > > > (courtesy of LeoNerd): > > > > > > generic_sort { $a <=> $b } { length $_ } @strings; > > > > > > or (from my own code): > > > > > > loop host 'shadowcat' => { do_stuff; }; > > > > > > I'm fine with doing the work to add this feature. I would just like to > > > be sure I don't break half of CPAN with my efforts. > > > > > > Thoughts? Comments? Rallying praise? Rotten tomatoes? > > > > How is the interpreter to know that those arent hashes? > > > > Yves > > Because I asked it to with a (&&) or ($&) prototype. sub do_stuff($;&); # implementation not important, I think. my %foo; my $foo; do_stuff $foo { 'something here' }; Now, is that passing in $foo as the first parameter and a code ref that returns a static string as the second, or passing in a value contained in %foo as that first parameter, and no code ref? Don't get me wrong, I've wanted to be able to put & somewhere other than the first parameter on many occassions. But first the syntax has to not surprise the reader[0], and we use enough squiggles already for so many different purposes, especially the braces, so a bit of care might be required. [0] Surprise with new syntax is fine. Surprise with something that could be one of multiple syntaxes, probably not so much.Thread Previous | Thread Next