develooper Front page | perl.perl6.users | Postings from October 2018

Re: sub name has unexpected interaction with s///

Thread Previous
Timo Paulssen
October 23, 2018 10:22
Re: sub name has unexpected interaction with s///
Message ID:
Hi Richard,

I wouldn't call s/// a routine. It's actually (implemented as) a kind of
quote, like Q, q, qq, qw, and also rx, and tr. I consider that an
important distinction, because the syntax with which you call s/// is
very different from how you call a sub. You can't just `say '(' ~ ')'
1234`, because regular perl6 syntax doesn't allow two terms in a row (in
this case the string ")" and the number 1234).

I'd say it more like "subroutines have precedence over some special
syntax", and "s/ b /x" will be parsed like "s() / b() / x()", but b and
x aren't defined, so it errors out at the end of compilation.

I hope that makes things a bit clearer
  - Timo

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About