18 ms·
A Review of Perl 6
- igravious 9y agoSuperb; enjoyable write up. Very witty in parts, no puns in sight. Makes me want to try Perl6 out.
- breatheoften 9y agoI also enjoyed the article but came away with absolutely no desire to ever use or encounter perl6.
- KGIII 9y agoThe 6 is for the number of users. ;-) On a more serious note, your comment is pretty much what I've seen most people say. I will probably poke at it, at some point. I won't have a good reason to do so, except just to learn.
- throwaway7645 9y agoThere is more than you think and I expect a decent amount of people to come over from Perl5, Ruby, and Python if the language gets optimized enough. Just for small stuff at first, but in larger numbers as the libraries start to show up
- inopinatus 9y agoI was similarly wondering what the killer application, platform, or tool will be. This review calls out the ease of FFI and a reasonable set of concurrency primitives so, in conjunction with the grammars and the data-mangling heritage, I conjecture that Perl6 might be good for IoT programming or SCADA. Of course it's a long trek from "might be good for" to "look at this compelling thing we built with it".
- igravious 9y agoEach to their own. What's your brand of poison?
- breatheoften 9y agoFull disclosure: I'm not sure a language called perl will ever appeal to me -- I have amusing post-traumatic life memories of perl. My main perl using/learning experience was back in college for a IT job. I was using this tool called unattended[1] which was about automating windows xp installations ... Involved writing hacky perl scripts to do very hacky things -- with some amount of building on top of somebody else's injected (and in some cases dynamically generated) perl code -- in a context where the only way to run/test changes was to reboot a machine, initiate a complete windows installation, wait for it to finish, and then wait for various post-installation hooks to kick in and eventually get around to running your code... NOT a fun place to learn the many many random subtleties of $ vs @ variable dereferencing behavior or any of the other samples from the long list of surprising perl behaviors ... [1] http://unattended.sourceforge.net/index.php http://unattended.sourceforge.net/index.php I have a lifelong preference for languages which don't actively prefer obfuscation over clarity... If your expectation for your developer's workflow is such that calling a directory 't' for 'tests' is deemed a useful abbreviation -- then I just simply do not want anything to do with that workflow.
- elros 9y ago> no puns in sight > me want to try Perl6 out Given your own understanding of desirabilities, I'd recommend you to steer away from this community in particular. :-)
- s_kilk 9y agoPerl6 feels like it could be the ultimate language for Man, Machine, Mineral, and Beast, if only we could teleport into a parallel universe where it war already in widespread usage. The sense of sheer potential off the language is intoxicating. I like to imagine the Geth in Mass Effect run on a hybrid Perl6/Erlang platform.
- zoffix222 9y agoFunny you mentioning Geth... Perl 6's core devs use a bot named Geth to report new commits on IRC. And.... it's written in Perl 6 ( https://github.com/perl6/geth https://github.com/perl6/geth ) :)
- sanderjd 9y agoI really don't understand why you say that. Care to expand? I can't picture what problems I have that perl6 is the solution to.
- throwaway7645 9y agoWell, what kinds of programming tasks do you normally do?
- Baeocystin 9y agoIs that before or after they made their Faustian bargain with the Old Machines?
- s_kilk 9y ago
- wott 9y ago> Modifiers (i for case-insenstive is the most important one) can appear inside a regex when preceded by a colon. For example, this Perl 5 regex: > (Male|Female) (?:[Cc][Aa][Tt]|[Dd][Oo][Gg]) > would be translated to Perl 6 as: > (Male || Female) ' ' [:i cat || dog] Perl 5 does support this feature: (Male|Female) ((?i)cat|dog) or: (Male|Female) (?i:cat|dog)
- b2gills 9y agoAlso I would use ( Male | Female ) in Perl 6, as it tries to match both in parallel. The reason the version with || is in P5-to-p6 is that is how | works in Perl 5.
- pram 9y agoIts been endlessly stated but naming it 'Perl 6' was a huge mistake. Perl 5 has an enduring reputation for crufty, unmaintainable code written by graybeard sysadmins. I wrote a lot myself that I wouldn't want to ever deal with again. I think they would have benefitted from a clean break from a marketing perspective, especially considering it's completely different.
- thanatropism 9y agoI know the break from Python 2 to 3 is also a mistake, but I don't know which one. I learned Python 3 because it seemed that it was the new one, but to great confusion Python 2 is alive and default in Linux distributions.
- slaymaker1907 9y agoI think Ubuntu switched over to python 3 by default recently.
- makecheck 9y agoIf they still call the executable "python" then they’re demonstrating the whole issue with keeping the same name for wildly-incompatible upgrades: it “shouldn’t" matter what version a reasonably-modern OS chooses and yet it does, solely because of the name. No one would complain about having "/usr/bin/python", "/usr/bin/py3k", "/usr/bin/perl" and "/usr/bin/rakudo" all at once on the same OS but being forced to choose two is insane.
- cat199 9y agoSo like, the same thing that happened between various perl versions (inc 4x -> 5x) and python? Or C++ versions? or even c-library or executable format changes? Things break sometimes.
- gkya 9y agoI don't get all this confusion wrt Python 2 and Python 3, it's not different from GCC supporting different C standards. Just run the correct executable (i.e. python2 or python3) and done. In response to parent comment, Perl 6 is Perl. I don't think that it's difficult to understand that Perl is a family of languages, and Perl 6 is a more recent and sophisticated sibling to Perl 5. All of this is bikeshedding to me.
- 23409125 9y agoSubpar performance is a huge drawback of Perl 6. I usually don't program in Perl, but occasionally use it instead of sed. Compare, Perl 5 vs. Perl 6: $ time yes | head -n1000000 | perl -pe 's/y/n/' >/dev/null real 0m0.945s user 0m0.944s sys 0m0.016s $ time yes | head -n1000000 | perl6 -pe 's/y/n/' >/dev/null real 2m49.881s user 2m44.892s sys 0m2.184s Spending several minutes to do what can be done in under 1 second is just unacceptable.
- zoffix222 9y agoYes, performance is where most of the funding is currently going into. Bleed commits on VM for example, recently passed Perl 5 on speed with read-a-million-line-file-and-sum-up-number-of-chars bench ( https://twitter.com/zoffix/status/895684203550973956 https://twitter.com/zoffix/status/895684203550973956 ).
- 23409125 9y agoWhat are bleed commits?
- zoffix222 9y agoCommits that happened recently and aren't part of any release yet :)
- deleted 9y ago[deleted]
- colejohnson66 9y agoCommits that would go into the bleeding edge builds
- jacobolus 9y agoThe “cutting edge” of technology or craft is the newest / greatest stuff, pushing the field forward in new unexplored directions, by analogy to the cutting edge of a plow or a knife which slices through some uncut material or unbroken ground. I believe the metaphorical use of the term dates from the middle of the 20th century. The “bleeding edge” is a more recent term for the same idea, emphasizing that being at the cutting edge might involve danger to yourself.
- b2gills 9y ago「Man is amazing, but he is not a masterpiece」 Is different than the other two, it can be thought of as short for Q 「Man is amazing, but he is not a masterpiece」 While the others are short for qq “Man is amazing, but he is not a masterpiece” Which is short for Q :qq “Man is amazing, but he is not a masterpiece” Q :double “Man is amazing, but he is not a masterpiece” Which is also short for Q :s :a :h :f :b :c “Man is amazing, but he is not a masterpiece” Q :scalar :array :hash :function :backslash :closure “Man is amazing, but he is not a masterpiece” For more information see the [Quoting Constructs](https://docs.perl6.org/language/quoting https://docs.perl6.org/language/quoting) documentation. --- There are modules for [debugging and tracing](https://github.com/jnthn/grammar-debugger https://github.com/jnthn/grammar-debugger) Grammars. A regex is just a special kind of method by the way. say Regex.^mro; # ((Regex) (Method) (Routine) (Block) (Code) (Any) (Mu)) Which is part of the reason it doesn't have some of the niceties of parser generators built-in yet. The main reason is it got to a working state, then other features needed more designing at that point. --- # Perl 5 /(Male|Female) (?:[Cc][Aa][Tt]|[Dd][Oo][Gg])/ # is better written as /(Male|Female) (?i:cat|dog)/ In Perl 6 you can turn on and off sigspace mode /:s (:!s Male | Female ) [:!s:i cat | dog ]/ # or fully spelled out /:sigspace (:!sigspace Male | Female ) [:!sigspace :ignorecase cat | dog ]/ # or just use spaces more sparingly /:s ( Male| Female) [:i cat| dog]/ Note that in this case it is more like /( Male | Female ) \s+ [:i cat | dog ]/ In other contexts it could be slightly different. Basically it ignores insignificant whitespace. Note that `( a || b )` is more like the Perl 5 behaviour, but `( a | b )` tries both in parallel with longest literal match. Regular expressions are also the reason `:35minutes` is in the language by the way say 'a ab abc' ~~ m:3rd/ \S+ /; # 「abc」 Rather than make it a special syntax, it was generalized so it can be used everywhere. --- The asterix in a Term position turns into a Whatever, when that is part of an expression it turns into a positional parameter of a WhateverCode. $deck.pick(*); # randomized deck of cards $deck.pick(Whatever.new); # ditto $dice.roll(*); # infinite list of random rolls of a die $dice.roll(Whatever.new); # ditto %a.sort( *.value ); # sort the Pairs by value (rather than key then value) %a.sort( -> $_ { .value } ); # ditto Note that the last asterix was part of an expression, while the others weren't. my &shuffle = *.pick(*); # only the first * represents a parameter to the lambda # the other is an argument to the pick method The main reason I think for its addition to the language is for indexing in an array @a[ * - 1 ]; Rather than make it a special syntax exclusively for index operations, it was made a general lambda creation syntax. I will agree that it takes some getting used to, but it is not intractable. WhateverCode lambdas should also only be used for very short code, as it can get difficult to understand in a hurry. --- A `$_` inside of `{ }` creates a bare block lambda, basically this removes the specialness of Perl 5's `grep` and `map` keywords. There is a similar feature of placeholder parameters `{ $^a <=> $^b }` to remove the specialness of Perl 5's `sort` keyword. Another feature is pointy block, which removes the specialness of a `for` loop iterator value syntax. # Perl 5 (this is the only place where this is valid) for my $line (<>) { say $line } # Perl 6 for lines() -> $line { say $line } # not special lines().map( -> $line { say $line } ); # really not special if $a.method-call -> $result { say $result } --- There is more to NativeCall that you haven't discovered yet. For example, you can directly declare an external C function as a method in a class, and expose it with a different name. (if the first parameter is the instance) Also it doesn't matter what you put in the code block for a NativeCall sub, as long as it parses. That is why it doesn't matter if you put a Whatever star (asterix) there or a stub-code ellipsis `...` in it. (you can also leave it empty) use NativeCall; sub double ( --> size_t ) is native() is symbol<fork> { say 'Hello World' } say double; say '$*PID == ',$*PID; # 1555 # 0 # $*PID == 1552 # $*PID == 1555 --- Supplies can be pattern matched, just use `grep` on them as if they were a list. It in turn returns a Supply. You can also call `map`, `first`, `head`, and `tail` on them. Basically every List method is also on a Supply, along with special methods like `delayed`. --- A lot about what you talked about with lists, and itemization is something that does take some time to get used to. It does get easier, but is always something you have to be cognizant of. Sort of like returning lists from subroutines are from Perl 5. It allows control over flattening that isn't available in Perl 5.
- thyrsus 9y agoTo what extent is Perl 6 now stable? I was at a LISA conference in December 2011, and watched Tobias Oetiker present the wonders of Perl 6, and though I loved what I saw, something more than a tenth of his examples broke because of recent revisions, whether semantic or to implementation. God bless the language explorers, but my takeaway was "not yet". Is now the time?
- fnj 9y agoI would say perl6 was stable as of the Christmas 2015 release of rakudo.
- Ultimatt 9y agoBeen rock solid stable with respect to the language changing since the spec release over a year ago, especially if you specify that version in your program. I've been tinkering since 2010 and it was increasingly nuts how frequently things like list/string implementation and even syntax would change. So yeah its now a fully released stable language. The thing you might then wait for is performance. But it's getting better rapidly. The Text::CSV benchmark is probably the best to see perf getting there http://tux.nl/Talks/CSV6/speed4.html http://tux.nl/Talks/CSV6/speed4.html
- kibwen 9y agoThis is an interesting article overall, but I'm unsure what this part is trying to say: > Perl 6 is aware of graphemes and combining codepoints, and unlike Python, Swift, or Elixir, Perl 6 can can access arbitrary graphemes by position in constant time, rather than iterating over every grapheme to access a particular one. [...] Graphemes are stored internally as 32-bit integers; this address space is large enough to contain all legal codepoint combinations It sounds like Perl6 is simply storing strings as UTF-32. AFAIK, there's nothing called a "grapheme" in Unicode; the closest I know of are "grapheme clusters", which are theoretically unbounded in size and so cannot simply be stored in a 32-bit integer. Maybe by "grapheme" the author means "Unicode scalar value"? But being able to access those in constant time isn't especially useful, AFAIK.
- deleted 9y ago[deleted]
- cygx 9y agoPerl6 extends (NFC normalized) UTF-32 with autogenerated 'synthetic' codpoints for grapheme clusters. This yields an upper bound for the number of unique multi-codepoint grapheme clusters a Perl6 program may encounter (something like 2^31 as I believe only negative numbers are used for synthetics).
- ktRolster 9y agoSince this representation is internal, it means that if there is ever a need for more clusters, they can switch to 64 bit integers without breaking any compatibility.
- cygx 9y agoCorrect. I should also have clarified that my comment applies to Rakudo Perl6 running on MoarVM. As far as I'm aware, other backends are still behind in implementing proper Unicode semantics.
- kibwen 9y agoIs there a document somewhere describing Perl6's string implementation more precisely? To the best of my knowledge this can't be done, since not only is it legal for combining characters to appear an unlimited number of times in a single grapheme cluster, even discounting repetition the number of legal combinations of single combining characters is surely larger than 2^31. It seems self-evident that if all theoretically-legal combinations of codepoints fit into a 32-bit space, then we just wouldn't bother with combining characters and would use precomposed glyphs exclusively!
- zaro 9y ago> ... but I personally prefer to be treated like a responsible adult rather than, for instance, a teenager trapped in the father-knows-best house of Go. My feelings exactly.
- lostcolony 9y agoOh, -I- should be treated like a responsible adult, -but those maniacs I work with shouldn't be-. Is the language for individuals, or for teams? Is it for software developers, or dabblers from other domains who have to crank out a bit of code?
- atemerev 9y agoPerl always was, and still is, a hacker's language. It is for individuals who want to get shit done NOW, disregarding maintainability or teamwork. For this particular niche, it is indispensable.
- lostcolony 9y agoNot saying otherwise. I, personally, prefer languages I can come back to a month later and figure out what the hell -I- was thinking, let alone someone else, but I understand the appeal. My point was that it's not really a pro/con of a language on whether it favors individuals hacking, or teams developing, but merely a consideration for its appropriateness to your problem, and so to say "I prefer" needs to be qualified as to -when- it's preferable.
- throwaway7645 9y agoThere's a lot to learn in P6 (I'm not an expert at all) and you could definitely beat anyone except for an APL developer in an obfuscated code contest IF you wanted to. However, I find the majority of P6 to be quite pleasant to read and terse to write...a nicely optimized ratio.
- zaro 9y agoI and the maniacs I work with should be treated as reponisble adults. IMHO the issues are never with technology itself, it's the people. And whatever language or technology you are using won't make any difference if the people themselves don't want to work as a team.
- bloaf 9y agoThe "whatever star" seems like a less-well-implemented version of Wolfram Language's pure anonymous functions: http://www.wolfram.com/language/elementary-introduction/2nd-ed/26-pure-anonymous-functions.html http://www.wolfram.com/language/elementary-introduction/2nd-... Essentially, WL uses # instead of * and requires a "&" to indicate when you're done defining your function. So the WL equivalent to Perl's (1, 2, 3).map: * * 2 is Map[ #*2&, {1,2,3}] (idiomatically you would use /@ as shorthand for Map[], so it would be) #*2&/@{1,2,3} Except WL is far more general with what you can do with #, and you can do things like this: Outer[ #1 * #2 &, {1,2,3}, {4,5,6}] which returns {{4, 5, 6}, {8, 10, 12}, {12, 15, 18}} because #1 * #2 & defines a function of two arguments, and "Outer" feeds the lists into that function. You can even use ## to refer to all the arguments passed into that function (regardless of how many arguments there are), so Outer[## &, {1, 2, 3}, {4, 5, 6}] returns {{1, 4, 1, 5, 1, 6}, {2, 4, 2, 5, 2, 6}, {3, 4, 3, 5, 3, 6}} And you can even do stuff like: f[x_] := x^2 Outer[ #1[#2] &, {e, f, g}, {4, 5, 6}] to get {{e[4], e[5], e[6]}, {16, 25, 36}, {g[4], g[5], g[6]}}
- perlgeek 9y agoif you want a more general way to create anonymous functions in Perl 6, it's not that many more keystrokes away: sub ($a, $b) { $a + $b, [1, 2, 3], [4, 5, 6] } Or even sub { $^a + $^b, [1, 2, 3], [4, 5, 6] } So yes, the whatever-star isn't the most powerful thing imaginable, but it's good enough for very simple cases, and more powerful mechanism are available too.
- bloaf 9y agoBut that's my point. Mathematica's # syntax is both. (i.e. it is good enough for very simple cases, and it is the more powerful mechanism.)
- lmm 9y agoScala had it before WL, with "_" which can be used with two or more arguments where necessary. I suspect other languages had it earlier than that. It's a very useful shorthand, although it becomes less necessary with properly first class functions and/or currying by default. E.g. I don't know if Haskell has it at all, but it doesn't need it.
- pascalxus 9y agoLately, I've been seeing more pots on Perl. Is it just confirmation bias? or is Perl making a comeback?
- ruleabidinguser 9y agoHopefully it's making a comeback.
- throwaway7645 9y agoPerl did show back up in the TIOBE rankings as #10 and then #9 (Perl5). There are plenty of blog posts and conferences...just not as much as Python, Java, C#...etc. Perl6 is starting to get checked out by the first wave of people who like to dive into new tech, so a bunch of blog posts have been showing up recently.
- rurban 9y agoperl5 is certainly dying (but still strong on legacy). development stalled for 20 years. perl6 is doing the worse-is-better approach, by focusing on all thinkable features (sans structural matching and proper destructuring), but with a performance making it unsuitable for production. there are some perl11 projects (5+6): cperl and rperl which solve both problems. suitable for production, proper performance and proper features.
- deckiedan 9y agoPerl6 is fascnating! And there arent a lot of 'woah' new languages about (Rust, Go, elixir, D, elm, nim, clojure, typescript, are all 'old hat' now...) so for people wanting to learn & play, perl(6) offers a lot of fun.
- frubar 9y agoI think it's you, I've seen nearly nothing about perl anywhere for quite a while.
- fnj 9y agoI found this a nifty intro to perl6. I am a 70 year old retiree and have 37 years of C programming and some C++, perl5, and other languages. This is the first time I've been able to make the slightest headway digging perl6.
- pcunite 9y agoI am a 70 year old retiree and have 37 years of C programming That's awesome. Thank you for joining the community here. I have a lot of respect for our elders. New technology gets written about using old technology.
- sethrin 9y agofnj is also a longtime community member of Slashdot, and well regarded.
- a1815 9y ago> I am a 70 year old retiree and have 37 years of C programming and some C++, perl5, and other languages Sir, when I grow up, I wish to have the same passion as you!
- hzhou321 9y agoIt is not a review. It is an introduction or tutorial.
- _pmf_ 9y agoHow's the toolset on Windows? Last time I checked, there were no out-of-the-box IDEs that supported debugging for Perl 6.
- bobjordan 9y agoTooling is the main issue for me. I love reading about Perl6 but would be hard to break away from IDE like Pycharm or Visual Studio Pro/Ent.
- Ultimatt 9y agoThere are some great things in Atom for linted editing with doc integration https://github.com/azawawi/atom-perl6-editor-tools https://github.com/azawawi/atom-perl6-editor-tools If you want to get hold of the latest stable full release you can use chocolatey which is kept up to date https://chocolatey.org/packages/rakudostar https://chocolatey.org/packages/rakudostar or use a .msi installer from the official Rakudo site.
- _pmf_ 9y agoThank you; I'll be sure to try it out.
- pavlov 9y agoThis line from the article best summarizes it for me: Perl 6: The Ruby on Rails of command-line tools.
- pvdebbe 9y agoThis reads like a literary review. I like the style a lot!
- wodenokoto 9y agoA lot of people here seems to think there is a lot of potential for perl6, with the only complaints being the name and its speed, with at least speed expected to improve. But I thought this review sounded pretty damning. Numerical operations are opaque as you never quite know if it's a rational or a float. The grammar engine is inferior to other languages 3rd party modules, hard to debug and seems to not be suitable for its main purpose (parsing perl6!) Everything seems to be writable in a multitude of ways with no clear indication if these ways are functionally different. I do a lot of NLP in python and I wish for better tools to munge and clean up my text data, and have been curious about perl6, but after reading this review I don't find Perl all that enticing at all.
- perlgeek 9y ago> Numerical operations are opaque as you never quite know if it's a rational or a float. Not so. When you put in floats, you get floats out. If you want always-rational numbers, put in FatRat and you get out FatRat -- with the predictable bad performance on algorithms that converge on irrational numbers. > The grammar engine is inferior to other languages 3rd party modules Nothing stops you from using superior 3rd party modules in Perl 6. Heck, you can use Python modules through Inline::Python in Perl 6. > hard to debug I haven't found it harder to debug than other parser libraries, but your mileage my vary. I'm a fan of Grammar::Tracer, which hasn't failed me yet. > Everything seems to be writable in a multitude of ways with no clear indication if these ways are functionally different. That is true, but I find it irksome that you mention it right next to Python, which also has a multitude of ways to do different things, even though the Zen of Python says there should be just one way. Think string formatting, for example. I believe it's a trait of every programming language that doesn't set out to babysit you.
- wodenokoto 9y agoThank you for inputs on the specifics. Would you say the reviewer/author is misunderstanding Perl6, or that I am misunderstanding the review?
- 9y ago
- Sean1708 9y ago$ perl6 To exit type 'exit' or '^D' > 0.3 == 3e-1 False I'm really really not sure how I feel about this. Does anyone know why the decision was made to make exponential notation return a float while decimal notation returns a rational?
- grondilu 9y agoThe "e" notation is an explicit reference to the floating point representation, so it should obviously use it. But decimal literal numbers (that is, not using the "e" notation) are best represented with rational values, in the sense that they don't need any approximation, so there really is no reason to use floating points for them.
- nerdponx 9y agoIs it though? To me it's just "scientific notation".
- Sean1708 9y agoExponential notation doesn't need any approximation either, xey just means x * 10 * * y, and both x and 10 * * y must be rational numbers.
- ryebit 9y agoThe "e" notation is just a shorthand for multiplying by a power of ten. I was kinda surprised when the article stated that "5.23e5" wasn't treated the same as as "5.23 * 10 * * 5". Mathematically, rational to an integer power is always rational. This strikes me more as a half-measure that can cause surprise and unpredictability. edit: can't get double-asterisk to get through HN's markup :(
- grondilu 9y agoFine, but then how do you suggest one should write floating point literal values? PS. I guess there is the "f" suffix as in C++. Well, for some reason that's not what Perl 6 decided. I, for one, think it's simple enough to use the "e" notation. If you want to write a Rat with a power of ten, you can always literally write say 1.2*10**3
- floatboth 9y ago> Perl 6 has Perl’s regexes with a few changes: extending the Unicode support, moving the modifiers around, and reassigning some symbols, and also changing the whitespace rules to be more legible. So… Perl 6… has Perl-incompatible regular expressions?? Amazing.
- Ultimatt 9y agoIt also has all of the Perl 5 regex syntax too, so you can still use anything legacy or if you prefer to stick to something more portable. It's just the "default" regex is the new syntax. You can also put in any other "language" for them that you feel like, so POSIX maybe shell glob? I think at least POSIX probably exists in the ecosystem ;)
- grondilu 9y agoI'm a bit disappointed about grammars. Usually, when I try to use them, it gets difficult. Especially when recursion is involved. Lately, for instance, I was reading the ECMAScript 2016 reference, and in it they define a repetition of elements with recursion[1]: ArgumentList: AssignmentExpression ArgumentList , AssignmentExpression I've never managed to do something like that with Perl 6's grammar. Basically every time I try to use recursion, it doesn't quite work unless I do some tricks. Maybe I ask too much, I don't know. 1. http://www.ecma-international.org/ecma-262/7.0/index.html#sec-ecmascript-language-lexical-grammar http://www.ecma-international.org/ecma-262/7.0/index.html#se...
- Ultimatt 9y agoHuh? Not sure I know what you mean, because something like the following trivially works? grammar LOL { rule TOP { <string> } rule string { <[a..z]><string>? } } my @lulz = LOL.parse("abcdef"); say @lulz; --- [「abcdef」 string => 「abcdef」 string => 「bcdef」 string => 「cdef」 string => 「def」 string => 「ef」 string => 「f」]
- grondilu 9y agoI didn't say recursion never works. I say most of the times, it doesn't. There is no alternation in the example you provide, for instance. Had you written it like this: grammar { rule TOP { <string> } rule string { <[a..z]> | <string><[a..z]> } } as inspired by the rule mentioned above in the ECMAscript reference, it would fail.
- zengargoyle 9y agoI'm probably off the mark a little bit.... but 'rule' implies that whitespace is really <.ws> (totally ignored white space matching thingy). '|' is the Longest-Match-First (different from Perl/PCRE/etc). LMF is not possible in the case where it is not a DFA... the implicit <.ws> that is there by using 'rule' and having a space might be your problem... :) TL;DR Don't forget that 'rule' does <.ws> magic. This may or may not actually be part of the problem... I have seen a similar sort of thing and only half understand the answer i got.. Check your implicit <.ws> and '|' LMF.
- nerdponx 9y agoAs a general comment, I would love to see more "reviews" of programming languages like this, even ones that are already in, use but maybe only in one niche, or should perhaps be more popular than they are.
- dom96 9y agoI thought the same thing. In particular I would love to hear what the author has to say about the Nim programming language.
- donaldihunter 9y agoIf you want good error reporting from grammars then you really need to implement a FAILGOAL in the grammar. For example: method FAILGOAL($goal) { die "cannot find $goal near position {self.pos}" } There is also a very helpful grammar tracer and debugger when developing a grammar: use Grammar::Tracer; or use Grammar::Debugger; https://github.com/jnthn/grammar-debugger https://github.com/jnthn/grammar-debugger
- thormick 9y agoI managed to not only read that several times over as FAILGOAT, but think that, yes, that sounds like an awesome solution.
- cafard 9y agoExcellent, thanks.
- mncharity 9y agoFWIW, I note my own trigger for revisiting Perl 6, is the existence of a standards-compliant transliterating implementation of another language, say Javascript, written in Perl 6. No ambiguity, just "does it pass the validation suite?", and "how fast is it?". A decade of "it's usable now!" has left that sentence with little signal weight for me. The idea is, at least as of a decade ago, it was straightforward to massage the then ECMA spec into Perl 6 code. The spec says "Go to step 4 ... 4. ..."? Well, "goto Step_4;... Step_4: ..." is code. And so on. Perl 6, at least as envisioned then, is a very nice language for language implementation. Implementation often goes like this: most of the language is easy, nicely compatible with the target; some of it is hard, requiring some struggle to impedance match; and tiny bit of it is impossible, or nearly so, or requires rewriting all the rest, because of "gotcha" conflicts with the target semantics. With a rich kitchen-sink target, almost everything becomes easier, and there's likely some hook you can use to get that impossible bit done. And when writing a compiler, (then, almost) general grammars, and multiple dispatch with type sets, is a nice place to be. But the corollary is, when I don't see a compliant ES2017 transliterated to Perl 6, then I assume something is wrong - something isn't working yet - be it unfortunate spec, or "doesn't quite work yet at scale" implementation, or community.
- gfodor 9y agoAre there any good examples of projects like this that drag on for an eternity and somehow, despite the odds, release, and also become extremely successful? It seems like after a certain point you have basically missed the boat on delivering value based on the assumptions you had when starting the project.
- raiph 9y agoDo you consider Haskell to already be extremely successful? (Haskell planning began in 1987, the same year Perl 1 shipped.)