Patrick (>): > 1. I suspect this method really belongs in src/builtins/any-str.pir > instead of the C<Str> class, so that we can do replacements on > the stringification of any invocant (not just C<Str> objects). > > 2. The :multi() is likely incorrect, even as a method of C<Str>. > Any object should be usable as a pattern/replacement, not just > C<Str> objects. For example, I think that these ought to > be equivalent: > > $foo.subst('3', '4') > $foo.subst(<3>, <4>) > $foo.subst(3, 4) > > I.e., the caller shouldn't have to be concerned about coercing > the parameters to C<Str> objects in order to invoke the builtin > C<subst> method.
I agree. I also like the new, more flexible behaviour much better: $ ./perl6 -e 'say (2 ** 5).subst(/3/, 4)' 42 New patch attached.
subst-any.patch
Description: Binary data