Hi,

I've recently seen the slides of Dave Mandelin "Know your engine - How to make your JavaScript fast" [1]. If I understand slide 121 correctly, then a type inference engine can know in some cases if all elements of a (dense?) array have the same type.

On the Harmony proxies proposal, one open issue is the following:
"Traps that return arrays of property names, such as getOwnPropertyNames: should all values in the returned array be coerced to String before being returned to the user? (...)" Regardless of how the problem is seen, considering such a things would require to look at the type of each element and convert it if it's not a string. Assuming that programmers already generate arrays of strings (the strength of this assumption would need investigation) and assuming that the engine is able to realize it in most cases (needs to be investigated as well), then the cost of verifying the invariant is cheap. My point is that in good cases, enforcing the invariant "has to return an array of strings" in good cases may be cheap (at least cheaper than with a naive approach).

Of course, the assumed cheapness of the invariant enforcement in good cases depends on having a type inference engine able to do such checks. If I understand well, Mozilla has one able to do that (tell me if I'm wrong) and it's open source. Other may have different opinions, but I think that if there was another different open source type inference engine with the same capacity, then having such an engine could be considered as "not that hard", because anyone who would like to create one could at least see 2 different approaches and implementations.

David

[1] http://www.slideshare.net/newmovie/know-yourengines-velocity2011
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to