[Ometa] True higher order rules

Loup Vaillant l at loup-vaillant.fr
Mon Mar 19 04:36:35 PDT 2012


Higher order rules are currently used like this:

   ometa Foo {
     until :rule = apply(rule)
                 | anything until(rule),
     close       = ']',
     until_close = <until('close')>
   }
   Foo.matchAll('yada]yada', 'until_close') // prints 'yada]'

So, to pass the rule 'close' as a parameter, I have to refer to it by
name (as a string), then invoke it with apply(). This causes 2 problems:

  - I can't pass around anonymous rules. (this is a limitation of
    Ometa's syntax)

  - I can't do partial application:
      foo('bar(baz)') // ankward attempt at partial application.
                      // of course, it will fail miserably, as there is
                      // no rule with parentheses in its name

In an ideal world, I'd like to be able to write:

   ometa Foo {
     until :rule = rule           // apply() is now unnecessary
                 | anything until(rule),
     close       = ']',
     until_close = <until(close)> // no quote around 'close', it is
                                  // passed directly
   }

Or even better:

   ometa Foo {
     until :rule = rule
                 | anything until(rule),
     until_close = <until(\']')> // no, I don't mean the character ']'
                                 // So I added a Haskell-like backslash
                                 // to represent a "lambda" anonymous
                                 // rule.
   }

Now the question is, why Alessandro didn't do this in the first place?
Are there implementation difficulties?  Which are those?  I'm currently
trying to port OMeta to Lua, so it would be good to know.

Thanks,
Loup.


More information about the OMeta mailing list