3 ms·
True. I'd argue that it's the best of both worlds: Unlike Java, you have access to a bunch of helpful functions on every primitive, and you can add more by modi
by TrevorBurnham 15y ago
True. I'd argue that it's the best of both worlds: Unlike Java, you have access to a bunch of helpful functions on every primitive, and you can add more by modifying prototypes; and unlike Ruby, primitives are immutable, which puts a cap on the level of complexity (you could write a whole book on Ruby's string objects).
- LeafStorm 15y agoYou could do something similar by having each primitive type share a global prototype á la Lua's "string" metatable. Most operations are implemented as primitives in the VM, but any non-primitive operations on primitive types go to the type's metatable.