5 ms·
Something like: implementing your own small if/else DSL [1]! I'm not saying that this is a good idea. I am saying that this is possible with overriding the meth
by melvinroest 4y ago
Something like: implementing your own small if/else DSL [1]! I'm not saying that this is a good idea. I am saying that this is possible with overriding the method dispatch :')
In Pharo (a Smalltalk descendant) one needs to override the doesNotUnderstand method.
The thing is: the whole DSL that I made (with if/else/elif) is its own method call. It's exactly one method call. So if you write "code" like that, then you'll always have a variable length type of method call that Pharo won't understand. By overwriting it and checking for the right symbols (If, Else and Elif) one can group them together and mimic if-statement type of behavior.
I think it's really wild, awesome and fun.
[1] https://www.youtube.com/watch?v=BUEnRrUZ-Ug https://www.youtube.com/watch?v=BUEnRrUZ-Ug