4 ms·
I'm still not convinced it doesn't just sweep the complexity under the rug. Ultimately you still need to branch unless you only want the language to do pure ma
by jandrese 7y ago
I'm still not convinced it doesn't just sweep the complexity under the rug. Ultimately you still need to branch unless you only want the language to do pure mathematical computation or something like that. Only now every branch needs to be hidden in a function call.
- pmontra 7y agoI have a large Elixir project with less than 10 branches (if then else) and they were written by other developers. Conditional logic is done either in pattern matching in function definitions (and some guard) or case/cond or with/else. I guess case/cond can be implemented with the return mechanism of Chaos. Maybe it's going to feel weird, maybe not. There is no pattern matching and I got the feeling that's going to complicate things but again, it can be emulated to some degree but the return mechanism. Instead of def a(0), do: "a" def a(1), do: "b" def a(_n), do: "c" Probably we'll be writing str def a(n) num x = n end { x == 0 : "a" x == 1 : "b" default: "c" } Having to define that x variable feels like a waste of code and reasoning on x instead of n (the argument of the function) is a pity. Maybe the function body can be empty. I didn't install the language. I wonder how that scales on real world cases, for example matching the internals of some complex data structure.
- curryst 7y agoPattern matching is still branching. An elegant way of expressing it, but it is branching none the less.
- imtringued 7y agoI am now wondering what the benefit of Chaos' approach is. Chaos is making some pretty substantial tradeoffs. Going with conventional pattern matching (as part of the declaration) isn't such a big leap.