4 ms·
> In my 23 years of programming, I have never experienced this bug. I've also never heard of anyone else experiencing this. I've even said this in fora where I
by patrick451 4y ago
> In my 23 years of programming, I have never experienced this bug. I've also never heard of anyone else experiencing this. I've even said this in fora where I should have had someone pop up to correct me; a corollary to Cunningham's Law is that if you say something that should be controversial but nobody pops up to correct you, it must not be controversial after all.
This is such an odd claim. Mixing up a string for a list of strings, which both satisfy the iterable interface, happens all the time in python. Does the author, and his acclaimed fora simply not use python?
- lacyleathers 4y ago>Mixing up a string for a list of strings, which both satisfy the iterable interface But those are actual valid and useful implementations of the interface, nominative typing wouldn't save you.
- Smaug123 4y agoReally? Iterating over a string should give you some kind of {char, code point, grapheme cluster} or whatever; iterating over a list of strings should give you a string. Those are not the same type, and any nominative type system should surely realise this.
- lacyleathers 4y agoIf you step outside the generic interface, duck-typing would of course also give you a compiler (or runtime) error. Not sure what scenario you're imagining here.
- Smaug123 4y agoThe scenario I'm imagining here is precisely the parent's example of Python; isn't it one of the absolutely standard mistakes that everyone makes?
- lozenge 4y agoI've never intentionally passed a string to a function that expects a list of strings. But I have done it accidentally very often and received an incorrect return value (instead of an exception). I'm including functions like min() there, technically it can take a string argument, but I've never wanted it to.
- Phlogistique 4y agoThe thing the author has never experienced is someone accidentally implementing an existing interface, and then code expecting this interface to call that accidental implementation in a way that creates a bug.