Quasis: assignable substitutions?

Mark S. Miller erights at google.com
Sat Jun 18 19:57:31 PDT 2011


On Sat, Jun 18, 2011 at 5:59 PM, Mike Samuel <mikesamuel at gmail.com> wrote:
[...]

> >> What idiom should quasi handler authors use to distinguish a writable
> >> slot from a read-only slot?
>
[...]

> By read-only slot vs read-write slot I meant
>
> example`
>  ${x} is read only
>  ${=y} is read-write
> `
>
> I should have phrased that as read-only substitution vs read-write
> substitution using the alternate slot spec for SVE.
>

I think this is really just a special case of the general question "What
idiom should quasi handler authors use to distinguish what kind of value is
expected in a given hole position?" There's no general answer, and the
answer for a particular quasi handler depends on the user's understanding of
the purpose of the quasi handler. If the kind of thing expected at a given
hole position is a record with a zero argument get method and/or a one
argument set method, then ${=x} is just a particularly convenient method for
generating one on the fly whose two methods happen to provide read-write
access to x.

That said, for each hole position, the user's understanding of the meaning
of the quasi handler will usually be one of "consumes a value here", in
which case ${x} would be natural, or "extracts a value from the specimen and
assigns it here", in which case ${=x} would be natural.

Returning to a recent example, for regex capture positions, i.e., after an
unescaped "(", I'd always expect to see ${=x} unless something unusual is
going on. Elsewhere, I'd expect ${x} to provide text to match against. If we
use this convention, then to provide text to match against after an
unescaped "(" that appears for other reasons, you'd use "(?:" instead. I
admit this is accident prone, but is I think still the best balance.

-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110618/6952b24b/attachment.html>


More information about the es-discuss mailing list