Exegesis 3 Released (Perl 6 Examples)
chromatic writes "On the heels of Larry's most recent revelation, the mad scientist of Perl (Damian Conway) has followed up with Exegesis 3. His article gives working Perl 6 code examples of Larry's design decisions." Lots of good stuff in here.
How can these be working examples when Perl 6 does not even exist yet?
Some of this new stuff seems to be seriously blurring the difference between language and library.
Of course it's cool to write something like @costs, but why must be an operator? It seems to me it would work just as well as an ordinary procedure.
I'm wondering if they are thinking about constructs to define new syntax at runtime. In Scheme for example most of the syntactic forms are defined in the library using define-syntax .
I do love the hell out of perl, but I sure hope I can "use English 'operators';" for things like the hyper-operators. 'course, maybe 'use English' is deprecated ... can't wait for 'use Chinese', imagine what perl would look like then...
I would much rather see "@diffs = @set1 ^- @set2" expressed as a list comprehension, say @diffs = (each $x - $y suchthat $x in @set1, $y in @set2); (assuming I have said "english operators" on, otherwise I would imagine at least the 'suchthat' operator would be some punctuation char). It's a bit contrived for something as simple as subtracting every member of a couple lists, but list comprehension is beautiful stuff when combined with lazy evaluation in languages like Haskell.
Oh, and Perl6 is going to have an 'in' operator, right?
I've finally had it: until slashdot gets article moderation, I am not coming back.
On the other hand, if you can obscure complex operations into short syntactic sequences, you can keep the programmer from shooting himself in the foot. Look at Java - its syntax is probably as plain and up-front as you can get, but the need to spell most things out explicitly means most programmers spell them out incorrectly. Therein lies the magic of some syntactic freakshows like regular expressions - imagine programmers defining their own NDFAs? I understand this is not a great example as other languages support perl-like regexes, but maybe you get my drift.
I think the conlcusion is that perl will be like Haskell and Lisp in a way (not a functional language per se) in that programming in perl will simply require a different approach and strategy. You'll have to think in perl in order to properly program in perl. It simply won't be for translating C into an interpreted environment or sh into a portable syntax, it'll be its own paradigm.
I believe there is extensive remodelling called for by the current Perl6 gameplan, although I think this will further distance Perl 6 from Perl 5 programmers, and most likely some of them will simply move on to other languages which don't seem like such moving targets (although with Python claiming a signficant rewrite in the future, there may not be much of a safe harbor outside of yuck Java).
100 < -s $filepath <= 1e6
is essentially equivalent to:
(100 < -s $filepath) && (-s $filepath <= 1e6)
except that the `-s $filepath' only gets evaluated once. We're supposed to be Wow! Neat! about that.
On the other hand, we are also told:
which may be cunning, except of course with wow neat multiway comparisons it is equivalent to ($a == $b) && ($b != NaN), which doesn't do the advertised job.Finally, lest we might suspect operators like < and <= are treated differently from == and != for purposes of this `feature', we are told:
Predict the ultimate (though probably not imminent) demise of multiway comparisons in Perl 6.