On Tue, Oct 10, 2006 at 10:49:11PM +0200, Juerd wrote: : [EMAIL PROTECTED] skribis 2006-10-09 0:22 (-0700): : > P5's s[pat][repl] syntax is dead, now use s[pat] = "repl" : : Why keep the s?
Because @Larry felt it was better to keep the intent out in front. : substr works perfectly as both rvalue and lvalue, and I think m[], also : known as //, can do the same. No need to do things based on delimiter : (bracket versus non-bracket), then. : : > + s[pattern] = doit() : : m[pattern] = doit(); : /pattern/ = doit(); We thought about that, but the intent is obscured. : > + $str.subst(/pat/, "replacement"); : > + $str.subst(/pat/, {"replacement"}); : > + $str.=subst(/pat/, "replacement"); : > + $str.=subst(/pat/, {"replacement"}); : : Hmmm... I have no answer for the non-mutating version, but: : : $str.match(/pat/) = "replacement"; : $str.m(/pat) = "replacement"; And I even predicted somewhere that someone would immediately ask for a method form of pseudo-assignment. But macros and dynamic dispatch don't mix well, and I think if you really want the macro it's just about as easy to write: $str ~~ s(/pat) = "replacement"; : > +This is not a normal assigment, since the right side is evaluated each : > +time the substitution matches : : Can't this be generalized somehow? Return an lvalue proxy, like substr : does, and make thunking the default for certain LHS types. Well, I'm not sure I like that much hidden run-time apparatus, and it doesn't solve the basic macroish problem that the replacement has to be a lazy thunk. : I don't like special syntax that looks like normal syntax. Then by all means also avoid these: has $.answer = 42; state $s = 0; :-) Larry