4 ms·
Great (basic) introduction with exception to the regex chapter because it felt like an introduction to regex instead of the regex features of perl6. Some thing
by user9756 11y ago
Great (basic) introduction with exception to the regex chapter because it felt like an introduction to regex instead of the regex features of perl6.
Some things I found interesting (in addition to what s_kilk mentioned and linked to and others have already mentioned some of them)
* Gradual typed!
* Multi subroutine
* Hyphen in variable names
* @numbers.=sort
* .WHAT
* Catch blocks
* .defined
* Unless
It will be fun :)
I however don't understand the reason for the naming of eg elsif, my, slurp/spurt?? (instead of else if or local or fread/fwrite) Is it a perl culture thing? Because they mention in the tutorial that Perl 6 belongs to the C-family languages (and then call the "for" loop in C "loop").
- username223 11y ago> I however don't understand the reason for naming of eg elsif, my, slurp/spurt?? Yes, it's for historical reasons. "elsif" is spelled that way in Perl 5. Perl 5 has both "my" and "local" to specify lexical and dynamic scoping, respectively, so Perl 6 using "local" for lexical scope would be confusing. "slurp" is a common term for reading the entire contents of a file at once.
- cafard 11y ago"my" arrived after "local". The former is true lexical scoping, the latter isn't quite.
- tbrownaw 11y agoRight. As gp says, "local" is dynamic scoping. It's available as long as the declaration stays on the call stack. It more-or-less allows globals to be temporarily redefined.
- DonHopkins 11y agoThink locally, act globally.
- omaranto 11y ago"my" is shorter than "local" or "let" and fairly evocative. Maybe you should ask why other languages don't use "my", instead. :P
- colomon 11y agoLet me address your last paragraph and expand a bit on what username223 said. elsif is historical from Perl 5; I think it may be related to the fact that C-style ifs require curly brackets in Perl. my is Perl 5, is different than local, and is gloriously short. Nicest way I've ever seen to declare a variable. :) slurp/spurt are routines to read/write an entire file at once. slurp is pretty standard in other languages, I believe, and spurt was chosen to be a natural opposite to it. Perl 6 still has open / close / read / write, etc. Though to be fair, honestly I usually use lines, which (with no other arguments) gives you a lazy list of the lines in standard input / files specified on the command line. for in Perl 5 was some weird combo which could be iterating over an array or a C-style for. In Perl 6, those have been separated. Because iterating over an array is vastly more common, that gets the shorter keyword. The C-style loop got the loop keyword.