Hello All,
I have been asking Autrijus about getting the substitution regexp
working in Pugs, and a few issues have come up which need some
clarification.
In the Smart Matching table in Synopsis 04, there is a mention of
'subst' (here is that snippet so you don't have to go digging):
$_ $x Type of Match Implied Matching Code
====== ===== ===================== =============
Any subst substitution match* match if $_ ~~ subst
This seems to be the first mention of 'subst', and no real
clarification followed after. I search the other Synopsis and found it
again, all the way a the very very very bottom of Synopsis 05, where it
is mentioned as a method form of s/// (again here is the snippet):
There are also method forms of C<m//> and C<s//>:
$str.match(//);
$str.subst(//, "replacement")
$str.subst(//, {"replacement"})
$str.=subst(//, "replacement")
$str.=subst(//, {"replacement"})
This though, only seemed to muddy the waters more.
Further discussion on #perl6 lead to more questions regarding subst and
s///. What follows is the list of questions raised by this
conversation.
Is subst an object/type?
Or is it a method of the Str object?
If it is an object ...
Does s/// produce a subst object?
Does a subst object .hasa rule object(s)?
If so can we extract those rule object(s) from it?
What exactly does a subst object do?
How does a subst object stringify?
Etc. etc. etc.
If it is a method ...
How would a method on the right hand side of ~~ work exactly?
Is
~~ s:perl5:g/a/b/
the same as
~~ .subst(rx:perl5/a/, "b")
or
~~ .subst(rx:perl5/a/, {"b"})
Thanks,
Stevan
Thread Next