Mark J. Reed skribis 2006-08-31 10:29 (-0400): > >Another issue is how we're going to pass arguments to this method. s/// > >has very special syntax, that I don't think we can easily replicate. > S05 says it's $str.subst(regex, string-or-block); presumably the flags would > go on the regex?
Ah, block. Still, though, How would you specify :g? It doesn't make a lot of sense on rx// -- just like you can't use it with qr// in Perl 5. > > I personally still prefer $foo.s/// and $foo.=s/// > I don't really like the combination of quotelike and method call syntaxes. > I would happily take "s" as a replacement for the method name, but I don't > think it can happily coexist with the operator. I was thinking of a postfix op (not normal postcircumfix, but quoting). Postfix ops happen to be called with the dot too, but aren't necessarily the same as methods. > > because I don't think substitution belongs in a smart match op. > Well, that's the reason for the method version in perl6. Which, AFAICT, > returns the new string instead of the Match object, which is as it should > be. The only thing I don't like is the name. :) No, the method just returns the new string. The "inline" substitution is still done with ~~ (although you can probably use .=subst too, but really I don't like that syntax at all.) I don't think using a method (even if called "s") is good huffman coding. My expectation is that copying substitution will be used much - perhaps even more than mutating substitution! $foo.subst(/foo/, "bar") $foo.s(/foo/, "bar") $foo.s/foo/bar/ Hm. I don't know how "but" works exactly, but in the realm of syntactic sugar, this is appealing: $foo but s/foo/bar/ (Note that while " but " is long, it's extremely easy to type.) Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html