Arc Forumnew | comments | leaders | submitlogin
1 point by dreeves 6064 days ago | link | parent

I like defpat. It looks soegaard's scheme solution does allow things like the a_Symbol check, right? Also, mathematica does allow destructuring arbitrarily complex lists:

  f[{{a_,{b_,c_,{{d_},e_}}}}] := g[a,b,c,d,e]


1 point by almkglor 6064 days ago | link

The problem in a lisplike is how to properly embed checks in destructuring binds. Since code represenetation == data representation, it's rather difficult to do:

  (defpat foo
    (x (isa x 'sym))
        (list x isa))
As it is, I'm already forbidding one symbol from being used for variables: quote. This is so that I can support:

  (defpat cmd
    ('niaw)   "cat"
    ('arf)    "dog"
    ('squeek) "mouse"
    (x)       (ero "unknown sound!"))

I don't know how scheme's pattern matching works; possibly yet another symbol has been removed from the allowed symbols.

-----

1 point by almkglor 6063 days ago | link

I've since added guards in defpat. See the arc-wiki, also http://arclanguage.org/item?id=2276

-----