3 ms·
> Scala transcends the static vs dynamic typing debate via it's duck typing. Hardly anyone uses duck typing in Scala (you probably mean structural typing, by t
by laureny 13y ago
> Scala transcends the static vs dynamic typing debate via it's duck typing.
Hardly anyone uses duck typing in Scala (you probably mean structural typing, by the way). There are plenty of articles explaining why structural typing is a bad idea, here is one:
http://goo.gl/0wcNFO http://goo.gl/0wcNFO
- mcv 13y agoThat article explains duck typing badly. In duck typing, you actually test if it quacks like a duck. His example doesn't, and just blindly assumes it can quack.
- anonymoushn 13y agoIs this really a worthwhile distinction? Using the first example from the Wikipedia article on duck typing, I have a choice between exploding when given invalid values: def calculate(a,b,c): return (a+b)*c or failing silently when given invalid values, which will often cause some other piece of code to explode, or at the worst cause some misbehavior that is difficult to detect: def calculate(a,b,c): try: a=a+b except: pass try: a=a*c except: pass return a or def calculate(a,b,c): try: return (a+b)*c except: return None I would prefer to just not be in the situation of choosing what to do with invalid values in the first place.