3 ms·
This is exactly how scala does it
by dtech 5y ago
This is exactly how scala does it
- matheusmoreira 5y agoYeah. It's also how Ruby and Smalltalk do it. Lisp also does similar things. In these languages it doesn't even make sense to talk about operators. They don't exist. There are only methods, functions. General ideas represented by a few universal concepts. No special cases. Of course they can be overridden... It would have been strange if they couldn't. They're just normal methods or functions.
- igouy 5y agoNo special cases; apart from the special cases ;-) Some Smalltalk methods are "compiled in-line" special — ifTrue: alternativeBlock "If the receiver is false (i.e., the condition is false), then the value is the false alternative, which is nil. Otherwise answer the result of evaluating the argument, alternativeBlock. Create an error notification if the receiver is nonBoolean. Execution does not actually reach here because the expression is compiled in-line." self subclassResponsibility
- matheusmoreira 5y agoThat's just the implementation though, isn't it? In the language proper, the method still exists. The implementation just compiles it away.
- igouy 5y agoHow would — "Of course they can be overridden..." — work when the method is: ifTrue: