4 ms·
> there's basically no sensible thing to do in these situations Are there any better options for dynamic languages when a weird coercion is going to be done? T
by seanwilson 8y ago
> there's basically no sensible thing to do in these situations
Are there any better options for dynamic languages when a weird coercion is going to be done? Throw an exception? Exit with an error? Convert to some special invalid_coercion value similar to NaN?
It's another reason static type checking (i.e. don't let the code run) is a no-brainer to me.
- gruez 8y ago>Throw an exception? Seems like the best choice rather than plowing ahead with assumptions
- jimmaswell 8y agoI feel like it's fine for languages in a web context to take a "the show must go on" attitude as they do. Partially working webpages (slightly broken html/js/etc) are generally much better than a blank page/error message or none of the js working at all.
- shawnz 8y agoDynamic languages are all about letting the caller decide what makes sense and what doesn't, rather than the callee. If you are too conservative with the input types you allow then it can create unnecessary coupling.