9 ms·
>accidentally treating the prototype as an instance can lead to modifying the prototype, which can then cause unpredictable consequences for all the other objec
by trashburger 4y ago
>accidentally treating the prototype as an instance can lead to modifying the prototype, which can then cause unpredictable consequences for all the other objects having that prototype
In my head, that's not how prototypes work -- prototypes are objects that serve as a template for other objects. The behavior of the object is defined by its _traits object_ which is pointed to by a parent slot. Therefore there is no difference between modifying the prototype object and its copies - sending the copy message to them will still yield the same result, and one does not affect the other. The only difference is that the prototype object is in a well-known location for copying convenience. Note that this does change once you modify the traits object, but that's not an operation you do lightly anyway.
> Java reflection is essentially read-only.
I believe part of this comes from the bytecode being read-only, no?
> The argument on the Java side, is that read-write makes optimisations (JIT/etc) a lot harder.
Self has proven that it's achievable[0].
[0]: https://raw.githubusercontent.com/russellallen/self/master/docs/papers/implementation.pdf https://raw.githubusercontent.com/russellallen/self/master/d...