3 ms·
This is a pretty good advertisement for Lisp. The Clojure article is about a piece of code. The Perl 6 article is about all of the syntax that you need to unde
by mechanical_fish 16y ago
This is a pretty good advertisement for Lisp.
The Clojure article is about a piece of code. The Perl 6 article is about all of the syntax that you need to understand before you can read the equivalent piece of code.
Including this gem:
That asterisk is a special value called Whatever. It generally does what you mean in a given situation.
Perl documentation is always good for a laugh. But, I wonder, what does "generally" mean?
...Due to a bug in Rakudo's handling of Whatever when combined with chained comparison operators, we have to write an explicit block for Adult.
Oh. It means that sometimes -- even in the context of a trivial nine-line example -- the damned asterisk will mysteriously fail and will force me to bang my head against the keyboard for half an hour until I finally figure out that I just can't use it. Because, apparently, this works:
subset Foo of Bar where *.baz < 16;
and this works:
16 < $bar.baz < 66
but this does not work:
subset Foo of Bar where 16 < *.baz < 66;
- ekiru 16y agoHi. I'm the author of the post. > The Perl 6 article is about all of the syntax that you need to understand before you can read the equivalent piece of code. I think it's more that the Clojure article just shows the code with very little explanation. Whereas my post was intended to demonstrate some of the basic capabilities of Perl 6's multiple dispatch and type system for people who aren't very, if at all, familiar with Perl 6. People unfamiliar with Clojure can probably guess what the code in the Clojure post does. I think I was able to (although I've dabbled in Clojure and Common Lisp, so I can't speak from the viewpoint of a total newbie to those languages). Some of the Perl 6 syntax I devoted paragraphs to explain were probably as clear as (defrecord Person [name age]), but I chose to explain them exactly to be sure that any readers unfamiliar with Perl 6 were able to know the exact semantics(e.g., that readonly attributes are the default). Some of the syntax is not something someone who has never heard of Perl 6 will be able to look at and know the meaning of immediately. Is that really such a problem, if the meaning of such features(sans bugs in the implementations) can be explained and fully understood in a couple of paragraphs and make things much more convenient for the person who does know the language? You learn them in a day or two and benefit from them for the entire time you use the language. In addition: the two pieces of code are not equivalent. The Perl 6 functions validate the types of their arguments. The age-group function can tell you the age-group of both a Person and an age. As well, if you want to write another multi dispatching on the age group of a Person, it's easier with the Perl 6, because you just have to do "multi can-have-kids-meal (Child $kid) { True }" and "multi can-have-kids-meal ($person) { False }". > But, I wonder, what does "generally" mean? It means that you should read the rest of the paragraph to see some examples of its uses. Don't worry, though, the actual spec (http://perlcabal.org/syn/S02.html http://perlcabal.org/syn/S02.html, grep for "The * character") is much more detailed. My explanation was a bit lackluster, I suppose, but I was trying to not devote much time to it, since the post is about multiple dispatch and the type system, not about the philosophy of DWIM as expressed in the simplicity and usefulness of Whatever. > Oh. It means that sometimes -- even in the context of a trivial nine-line example -- the damned asterisk will mysteriously fail and will force me to bang my head against the keyboard for half an hour until I finally figure out that I just can't use it. Well, more like five minutes (from time that I noticed the problem until the time that I had figured out the cause of the bug in Rakudo). But, yes, there are still bugs in Rakudo. I doubt this particular one will be around much longer(although it'll probably still be in this month's Rakudo *, since the compiler release was Thursday).
- berntb 16y agoThat did make me laugh: >>Perl documentation is always good for a laugh. But, I wonder, what does "generally" mean? First, this was about Perl 6, not Perl. Second, it was not official documentation, but from a (quite interesting) blog post -- which, as the author noted, explained the matter directly afterwards. I'm frankly expecting better from the clockwork fish.
- apag 16y agoYou do understand that “due to a bug in Rakudo” means that this is a limitation of the implementation rather than the language, and that it will be fixed in due time – right?