On Tue, Jan 21, 2003 at 03:52:30PM -0800, Dave Whipp wrote: > $a = sub ($a, $b) { ... } > $x = -> ($y, $z) { ... } > > The pointy-arrow doesn't buy anything here.
IMHO, it's actually a loss. I have yet to come up with any mnemonic for "pointy arrow means sub" that will actually stick in my brain. Every time I see this construct, I have to stop in my tracks and mentally flip through the reference manual. > But in a for loop: > > for 1,2,3,4 { ... } > for 1,2,3,4 -> ($a,$b) {...} > > its cuteness works because the brain sees it as a piping operator (even > though its not). Agreed. [snip] > And then we can replace the ~> with ->: > > for 1,2,3,4 > -> sub ($a, $b) { $a+$b } > -> sub ($a) { $a**2 } > -> { $^foo - 1 } > -> print; > > And this begs the question: what exactly does the C<for> contribute to > the semantics of the pipeline? What would C<map> (in void context) > do differently? One potential answer: make 'map' be lazy by default and 'for' be nonlazy (energetic? active? ADHD?). My logic in suggesting it this way around is that, to me, 'for' seems to operate more on a whole list, while 'map' is intended to operate on elements one after another. Like so: for (1,2,3) { print } # "I want to call print for this whole list" map { print } (1,2,3) # "Map the 'print' function over the elements # of this list" --Dks