digitalmars.D - stackoverflow.com question
- Andrei Alexandrescu (2/2) Jun 11 2011 http://stackoverflow.com/questions/6315882/pattern-matching-in-d
- bearophile (7/8) Jun 11 2011 Pattern matching is very useful if you have a functional mindset. In Has...
http://stackoverflow.com/questions/6315882/pattern-matching-in-d Andrei
Jun 11 2011
Andrei:http://stackoverflow.com/questions/6315882/pattern-matching-in-dPattern matching is very useful if you have a functional mindset. In Haskell functions are mostly based on it. But to implement pattern matching you probably need some kind of structural typing (this means two data types are seen as the same type if they contain the same fields in the same order, regardless of the names. Time ago I have vaguely asked for structural typing for D tuples), and some significant amount of added language complexity (Scala pattern matching has required several small things). So I don't think it's good to add pattern matching to D2. A possible *low-priority* idea is instead to allow arrays too and structs as items to switch on, to allow switching on bigInts too: http://d.puremagic.com/issues/show_bug.cgi?id=596 (I have said low priority because I think there are more important things to add.) Bye, bearophile
Jun 11 2011