3 ms·
Array.prototype[0] = 5; and make [] the same as [5]. Huh? I don't know what you mean by this. In lua you can easily replicate javascript's prototype inherit
by daurnimator 11y ago
Array.prototype[0] = 5;
and make [] the same as [5].
Huh? I don't know what you mean by this.
In lua you can easily replicate javascript's prototype inheritance.
- usrusr 11y agoBeing able to build it on top of the language and having it right inside basic language elements as an always-on possibility are quite different things. The former allows straight forward optimization of the simple case, simply accepting the performance hit of the stuff built on top (which still might benefit from some of those optimizations), while the latter forces the optimizer to invest a large effort into distinguishing between the simple case and the exceptional, and then there still needs to be an always-on fallback path from simple to exotic.
- groovy2shoes 11y ago"Prototype inheritance" is a fundamental building block in Lua, enabled via the metatable mechanism. It's by far the most common way to do OOP in Lua. I'd say it is, in fact, built right in to the basic language.