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

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

Thread Previous
From:
Timo Paulssen
Date:
October 23, 2018 10:22
Subject:
Re: sub name has unexpected interaction with s///
Message ID:
a5759ef6-7d2b-5ba1-2ee7-f1c9c16c72e2@wakelift.de
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About