On Wed, Oct 11, 2006 at 10:32:13AM -0400, Aaron Sherman wrote:
: @larry[0] wrote:
: 
: >Log:
: >P5's s[pat][repl] syntax is dead, now use s[pat] = "repl"
: 
: Wow, I really missed this one! That's a pretty big thing to get my head 
: around. Are embedded closures in the string handled correctly so that:
: 
:       s:g[\W] = qq{\\{$/}};
: 
: Will do what I seem to be expecting it will?

Yes, the right side is implicitly closurized and evaluated repeatedly
by the left side.

: How will that be defined in the Perl6-based parser? Will macros be able 
: to act as an LVALUE and modify their RVALUE in this way, or is this just 
: some unholy magic in the parser?

This is just a macro with a fancy "is parsed" rule, I think.  It eats the =
in complete disregard for precedence.  Nothing much to generalize, I think.

: >+     s[pattern] = doit()
: >+     s[pattern] = eval doit()
: [...]
: >+There is no syntactic sugar here, so in order to get deferred
: >+evaluation of the replacement you must put it into a closure.  The
: >+syntactic sugar is provided only by the quotelike forms.
: [...]
: >+This is not a normal assigment, since the right side is evaluated each
: >+time the substitution matches (much like the pseudo-assignment to 
: >declarators
: >+can happen at strange times).  It is therefore treated as a "thunk", that 
: >is,
: >+as if it has implicit curlies around it.  In fact, it makes no sense at
: >+all to say
: >+
: >+    s[pattern] = { doit }
: 
: Please clarify "quotelike forms", since to my untrained eye, the above 
: appeared to be contradictory at first (I read "quotelike forms" as s/// 
: not s{...}).

s{...} is also a quotelike form.  Basically I mean anything where
you get to choose your own quote characters, whether or not they are
brackets.

: Very interesting.

Yeah, we whacked on possible syntaxes a goodly long time on IRC the
other night.  Trying to balance out history and visuals and semantics
and failure modes was all quite interesting, but in the absence of
more Unicode keys on the keyboard I'm liking this notation pretty
well, particularly since we've already used pseudo assignment in
other places to thunkize the right side.

Larry

Reply via email to