On 02/04/2013 01:41 PM, Jacob Carlborg wrote:
On 2013-02-01 18:53, bearophile wrote:

Maybe Jacob Carlborg is able to show what kind of syntax for pattern
matching the macros are able to create (no need to actually implement it
now).

How would a pattern matching feature look like and behave?. I can see if
that would be possible to implement using the AST macros I'm thinking
about.


Well, ideally something like

ast.match{
    2*(?a)  => a+a,
    (?a)+2  => 2+a,
    (?e)    => e,
}

The following would be feasible today, hacking around the usual hygiene issues:

mixin(match!("ast",q{
    2*(?a)  => a+a,
    (?a)+2  => 2+a,
    (?e)    => e,
});

Reply via email to