Backtracking syntax includes:

    :, ::, :::, <commit>, <cut>

I like the way the ':' looks in patterns. But I noticed I have
several niggles about a number of other aspects of the
above syntax. All the niggles are minor, individually, but
they added up to enough that I thought I'd see what the
bikeshed might look like in another color.

First, the niggles:

1. It's nice how the ':', '::', and ':::' progression indicates
progressively wider scope. But I would be surprised if
newbies don't say to themselves, "now just how wide a
scope am I backtracking when there's three colons?".

2. Typo-trap: I can imagine it being fairly easy for some
people to miss, during debugging, both the visual and
behavioral distinction between '::' and ':::'.

3. It seemed odd how the <commit> and <cut> assertions
switch to the general <...> syntax. I felt like it would be better
if they avoided the general syntax, and preferably had some
family resemblance with the first three backtracking controls.

So, how about something like:

    :           # lock in current atom, ie as now
    :]          # lock in surrounding group, currently ::
    :>          # lock in surrounding rule, currently :::
    :/          # lock in top level rule, currently <commit>
    ://         # cut

Thus, redoing a couple examples from synopsis 5:

    m:w/ [ if   :] <expr> <block>
         | for  :] <list> <block>
         | loop :] <loop_controls>? <block>
         ]

    rule subname {
        ([<alpha>|_] \w*) :/ { fail if %reserved{$1} }
    }
    m:w/ sub <subname>? <block> /

--
ralph






Reply via email to