the special case in <| is an artifact of function manipulation being too
inconvenient in JS, and of <| being limited to literals (which is an
artifact of object cloning being considered tricky).
Even more so it is a matter that array, function, and RegExp objects
have special semantics ("internal methods") that are not obtained
via prototype inheritance and those literal forms imply the use of
those special semantics. If you want to clone object (and compose
objects) you have to worry about the "internal methods" and
whether or not you want them to propagate to the clones or what
it would mean to compose objects with conflicting internal methods.
This makes me wonder:
shouldn't all semantics specific to arrays be linked to the Array
prototype (and similarly for other literals with standard prototypes)?
[if not in current practice, then as a language design target]
given these special semantics, is it possible, in ES5 or in ES6,
to define a shallow clone function, such that original and
clone have separate own and [[Prototype]] properties, but
share the values of those properties as well as semantics?
Claus
>> the special case in <| is an artifact of function manipulation being too
>> inconvenient in JS, and of <| being limited to literals (which is an
>> artifact of object cloning being considered tricky).
>
> Even more so it is a matter that array, function, and RegExp objects
> have special semantics ("internal methods") that are not obtained
> via prototype inheritance and those literal forms imply the use of
> those special semantics. If you want to clone object (and compose
> objects) you have to worry about the "internal methods" and
> whether or not you want them to propagate to the clones or what
> it would mean to compose objects with conflicting internal methods.
This makes me wonder:
- shouldn't all semantics specific to arrays be linked to the Array
prototype (and similarly for other literals with standard prototypes)?
[if not in current practice, then as a language design target]
- given these special semantics, is it possible, in ES5 or in ES6,
to define a shallow clone function, such that original and
clone have separate own and [[Prototype]] properties, but
share the values of those properties as well as semantics?
Claus
This makes me wonder:
shouldn't all semantics specific to arrays be linked to the Array prototype (and similarly for other literals with standard prototypes)? [if not in current practice, then as a language design target]
given these special semantics, is it possible, in ES5 or in ES6, to define a shallow clone function, such that original and clone have separate own and [[Prototype]] properties, but share the values of those properties as well as semantics?
Claus