Hacker News new | past | comments | ask | show | jobs | submit login
Pattern Matching in a Dynamic OOP Language (stuffwithstuff.com)
14 points by danecjensen on Jan 17, 2011 | hide | past | favorite | 2 comments



I think the author may be interested in looking at user defined/dynamic patterns/extensible matchers or whatever the name is, as seen in F# and Scala

Basically where you can define your own pattern rule as a simple method in a class, and later use it for destructuring and matching, e.g.

    var Http= new Regex(stuff with (protocol)(domain)(path))
    var Http(protocol,domain,path) = "http://foo.com/bar" # variables protocol="http",domain="foo.com", path="/bar"  assigned
Which may be there in the language already, but I have not seen it mantioned


(active patterns in F#,

extractors or .unapply in scala




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: