3 ms·
> I'm not saying it's possible to avoid conditionals completely But it is. Smalltalk has no conditional statement, conditionals are implemented via polymorphi
by gnaritas 14y ago
> I'm not saying it's possible to avoid conditionals completely
But it is. Smalltalk has no conditional statement, conditionals are implemented via polymorphism on the subclasses True and False (ignoring compiler optimizations).
- cwp 14y agoYeah, but even in Smalltalk, lots of #ifTrue: messages are a code smell.
- gnaritas 14y agoOf course, you can write C in any language if you try hard enough.
- Roboprog 14y agoThat smells of a parlor trick -- passing one or two blocks / objects / functions to a boolean object to execute or not. Having said that, I like how many OOP languages implement loops as a special case of "visitor", though.
- gnaritas 14y agoIt's not a parlor trick, rather it's what it means to be object oriented. Traditional language constructs are built with object and methods as library rather than special magic keywords. Whatever the problem, Smalltalk builds the solution using objects, thus it is oriented towards objects. It doesn't just have objects, it's built out of them, Smalltalk "is" objects; library and language are the same thing. Your custom constructs are syntactically identical to core language constructs because it's all just library.