3 ms·
Having type annotations that are ignored at runtime would cause problems when you interact with code without type annotations, no? PHP has a (unfortunately qui
by TazeTSchnitzel 11y ago
Having type annotations that are ignored at runtime would cause problems when you interact with code without type annotations, no?
PHP has a (unfortunately quite limited) set of type annotations, but the interpreter actually enforces them.
- randallsquared 11y agoHow could adding ignored type annotations cause problems? Any problems that arise would have to be there without the type annotations...?
- aphexairlines 11y agoWithout the type annotations, you're expected to handle dynamic type checks yourself. With type annotations, you might think that tooling does it for you, so you might omit the dynamic checks. But the tooling doesn't necessarily check all your callers, and you end up with unexpected input. This is partly what the Typed Racket writers mean when they say that most gradual typing systems like this one are not sound. http://www.cs.cornell.edu/~fabianm/tpls/papers/20151110.shtml http://www.cs.cornell.edu/~fabianm/tpls/papers/20151110.shtm... http://www.ccs.neu.edu/racket/pubs/popl16-tfgnvf.pdf http://www.ccs.neu.edu/racket/pubs/popl16-tfgnvf.pdf
- lmm 11y agoIt can make debugging harder because "impossible" things happen - when a variable is annotated as a string you may not think to consider the possibility that it's actually an integer. But yes, optional typing is mostly just useless rather than actively harmful.
- ubernostrum 11y agoHaving type annotations that are ignored at runtime would cause problems when you interact with code without type annotations, no? I seem to be doing this a lot in this thread, but... This is your obligatory reminder that several statically-typed languages actually run on dynamic-language runtimes, because programmers don't like to think about the cost of polymorphism/generics, but implementers have to think about that.