in reply to Re^6: "a bit of sugar "(HOP)
in thread "a bit of sugar "(HOP)

make sub {...} have the same form as map {...} and grep {...}.

I didn't say that; I said that prototyping allows Iterator to behave like map { ... } and grep { ... }. And I agree, it also allows Iterator to behave like sub { ... }.

Meanwhile, curious about the origination of "syntactic sugar", I found this quote:

Syntactic sugar causes cancer of the semicolon;
And a hundred other goodies at http://www.cs.yale.edu/quotes.html.

Replies are listed 'Best First'.
Re^8: "a bit of sugar "(HOP)
by ikegami (Patriarch) on Mar 13, 2009 at 21:05 UTC

    I didn't say that; I said that prototyping allows Iterator to behave like map { ... } and grep { ... }.

    Then you're assuming Iterator(sub {...}) is the starting point, and that's nonsense.

    sub { ... } is the starting point, and it's already syntactically similar to map { ... } and grep { ... }. To say that (&) is needed to create the iterator while using the BLOCK syntax of map and grep is untrue. (&) is therefore irrelevant to the question at hand.

    Using Iterator is the sugar. It conveys information to the user without any effect on the program. (&) is only the means to make it happen.