3 ms·
Does Perl 6 have fundamental features that don't exist in other languages ? Just curious.
by zimbatm 11y ago
Does Perl 6 have fundamental features that don't exist in other languages ? Just curious.
- perlgeek 11y agoI don't know if any of these features are really unique, but the combination of having them all is certainly unique: * Strings that are made of Unicode grapheme clusters instead of codepoints or bytes. This means that a substr() operation for example can't even accidentally rip a apart a base character and a combining character on top of it * Grammars as a language feature * Gradual typing * A built-in meta object protocol * Concurrency based on high-level primitives (promises, queues, supplies, ...) with syntactic support (instead of threads and locks; which are still available if necessary, but discouraged, because they don't compose well). * Lazy lists
- Woodi 11y agoYea, grammars looks simple-the-unique thing other languages don't have in 2015, 2016 and, I bet, 2017 too. Maybe even longer :)
- kamaal 11y agoThat's only at level 1, until you realize Perl 6 code is parsed by a grammar written in Perl 6. Its power is amplified by the part Perl 6 regexes are better than anything there is out there. Even better, this extends beyond ASCII and applies to Unicode too. And will work with other powerful control structures. I'd fix that date to something like 2027.
- draegtun 11y agoWhile Grammars as a language feature aren't mainstream (yet!) they're not a unique feature either. For eg. See the parse dialect which is a TDPL that comes with Rebol / Red - http://www.rebol.com/docs/core23/rebolcore-15.html http://www.rebol.com/docs/core23/rebolcore-15.html - https://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/Parse/Parse_expressions https://en.wikibooks.org/wiki/REBOL_Programming/Language_Fea... - http://www.red-lang.org/2013/11/041-introducing-parse.html http://www.red-lang.org/2013/11/041-introducing-parse.html
- zimbatm 11y agoThank you
- gdwatson 11y agoGrapheme-cluster strings are neat, and the decision to normalize makes sense in that context. But how does Perl 6 handle filenames, which can't be safely round-tripped through grapheme strings?
- raiph 11y agoIt turns out that the same NFG mechanism developed to support graphemes works for this non-grapheme scenario too: "... POSIX doesn’t promise you’ll get UTF-8, or even ASCII. It promises ... a bunch of bytes. We can now cope with this properly – surprisingly enough, thanks to the power of NFG. We now have a special encoding, UTF-8 Clean-8-bit, which turns bytes that are invalid as UTF-8 into synthetics, from which we can recover the original bytes again at output. This means that any filename, environment variable, and so forth can be roundtripped through Perl 6 problem-free. You can concat “.bak” onto the end of such a string, and it’ll still work out just fine." From https://6guts.wordpress.com/2015/11/21/what-one-christmas-elf-has-been-up-to/ https://6guts.wordpress.com/2015/11/21/what-one-christmas-el...
- awwaiid 11y ago[minor syntax/markup edits] One that has caught my fancy are various uses of the "Whatever Star". This appears as a * in a few contexts. In many it is really a shortcut for the "Whatever" class, so you can use it in function signatures to enter sort of "automatic mode". @shuffled_names = @names.pick(*) # randomly pick... however many you have. whatever. But I think more interesting and different than that is using whatever-star as an automatic lambda thing. @nums.map(*/2 + 3) # expression-lambda from context around a whatever-star @nums.map( -> $n { $n/2 + 3 } ) # equivalent with a real stabby arrow lambda @nums.map( { $^n/2 + 3 } ) # $^n is a generated alphabetical-positional argument I suppose this isn't really fundamental... but is definitely different.
- deleted 11y ago[deleted]
- wantarray 11y agoI'm pretty sure that the "expression-lambdas" were inspired by Haskell, where you get a lambda simply by writing an operator with one or more missing operands. In Perl 6, detecting that an operand is "missing" isn't possible due to the existence of prefix/infix/postfix operators with the same names, so it expects a "whatever" star in place of the missing operand... :)