An interview with Larry Wall (LinuxVoice)
An interview with Larry Wall (LinuxVoice)
Posted Jul 24, 2015 21:52 UTC (Fri) by raiph (guest, #89283)In reply to: An interview with Larry Wall (LinuxVoice) by rsidd
Parent article: An interview with Larry Wall (LinuxVoice)
Sorry, my previous comment may have been confusing. The default Perl 6 number parsing now rejects a string that does not start with a decimal number.
> $ perl6 -e 'say "2" ~ "2" '
> 22
> $ perl6 -e 'say "2" + "2"'
> 4
> Why is this a good thing?
There are several things I can do with your question. I can consider it a simple, well-formed question and process it that way. I can consider it potentially dangerous, in part or whole, and process it on my own terms, picking out what's non-dangerous about the question and deal with that bit. Or I could just reject it as not something I am willing to process.
For subjective input, Python tends toward the third option, to keep itself and its users sane in their world. Perl tends towards the middle, to keep itself and its users sane in theirs.
> Why isn't it telling me that I can't use the "+" operator on strings?
Well, first, because you can. :)
If you don't want that you can stop it in a given lexical scope:
multi sub infix:<+> (Str, Any) { fail "nope" }
say "2" + 4 # dies with "nope" message
One of the design assumptions in Perl 6 is that companies, teams and individual developers, will want to tighten or loosen strictness to suit their own view of what's dangerous, what's ill formed. Perl 6 makes it simple to bundle such policies in to single `use` statements that apply lexically. And these can be added to the ecosystem so that those with a similar philosophical mindset for a particular use-case can easily follow the same policies.