3 ms·
OK let's say you have f, it only takes arguments a:Y, and b:Z. I call f(Z, Y). What happens? Does the machine segfault? Probably not.... so you're in "check th
by rtpg 6y ago
OK let's say you have f, it only takes arguments a:Y, and b:Z.
I call f(Z, Y). What happens? Does the machine segfault? Probably not.... so you're in "check the types at the callsite" territory. And honestly those kind of boundary checks are the problem, so to speak.
Are we doing static analysis of the entire codebase (a sort of closed-world theory?) You could maybe do something like this for non-exported functions, though at the V8 level that's tough.
I think that there would be possibilities to somehow get systems to be set up in a way to do more cleverness along these lines, but so long as you're taking in stuff from the outside world you end up needing to set up relatively costly checks, relative to the cost of the "default" JS semantics that you're trying to avoid paying.