3 ms·
Chances are those things were cloned from something else so you can simply clone that something else and put the clone in the array. AFAIK (though my knowledge
by Crinus 7y ago
Chances are those things were cloned from something else so you can simply clone that something else and put the clone in the array.
AFAIK (though my knowledge is limited) in Self there isn't a language-endorsed prototype like in JavaScript, instead an object is just a collection of slots and some slots can be marked as parent slots meaning that whenever slot lookup is made on an object, that object's parent objects will also be looked up. Prototypes are just a convention.
This implies that there isn't a "this is of class foo" connection (outside of manual conventions) and hence you do not have an "array of things" but an "array of objects" and each one of these objects can be anything - it is up to the rest of the code to ensure (or not) any similarity between the objects stored in the array.
FWIW the Self Handbook does seem to have a section on programming style and generally does seem to write a bit about how you are supposed to work with the system.
- masklinn 7y ago> AFAIK (though my knowledge is limited) in Self there isn't a language-endorsed prototype like in JavaScript, instead an object is just a collection of slots and some slots can be marked as parent slots meaning that whenever slot lookup is made on an object, that object's parent objects will also be looked up. That's correct, although incomplete: parents are only used when no "own" slot matches a message. Self will also trigger an error if two parents answer to the same message. > Prototypes are just a convention. Not so, however "prototype" has a completely different meaning in Self than it has in Javascript: a Self prototype is a mostly set-up object to copy, there is no semantic relation between a prototype and its "instance" afterwards. In Self, an object built to be set on a parent slot (and shared between multiple sub-objects) will be called either a trait or a mixin (depending on its parent chains, essentially). Self parent slots are no more and no less than built-in delegation. They can be used for inheritance (traits), they can be used for sharing implementation (mixins) or they can be used in the general context of composition (Go has echoes of this in struct embedding).