John Harris
10/24/2014 10:30:00 AM
On Thu, 23 Oct 2014 18:37:40 +0200, "Christoph M. Becker"
<cmbecker69@arcor.de> wrote:
>John Harris wrote:
>
>> On Tue, 21 Oct 2014 13:27:38 +0200, "Christoph M. Becker"
>> <cmbecker69@arcor.de> wrote:
>>
>>> Edition
>>> 5.1 (or maybe 5 already) introduced Object.seal()[1] which can be
>>> applied to the prototype object.
>>
>> It wouldn't be just the prototype object. It would be all the
>> user-defined objects in the prototype chain and each class instance
>> object as it is created.
>
>Usually you wouldn't seal the class instances, though, but rather
>prevent their extension and maybe remove the configurable attribute on
>the individual properties.
But that's what seal does!
>> All of which has to done by the Poor Old
>> Programmer, of course.
>
>The "Poor Old Programmer" could, however, write a function that does all
>this for him.
And then remember to write the code in the constructor to call the
function.
>>> Ecma-262 Edition 6 might introduce
>>> "maximally minimal" classes[2] and private name objects[3] which would
>>> provide better support for classes in the classical sense.
>> <snip>
>>
>> The current draft ES6 allows only one constructor function per class.
>
>This restriction applies to several object-oriented programming
>languages with classical inheritance.
Multiple inheritance in ECMAScript terms would change the prototype
chain into a prototype tree. Not all that difficult to do in
ECMAScript I suspect but very unlikely!
Multiple constructors, on the other hand, give you a choice of
parameters. You can already have new Thing() and new Thing(3,4) by
putting code in the constructor to look at the argument list and then
replacing missing arguments by default values : oh look, multiple
constructors.
Occasionally, though, you would like the same number of parameters of
the same type with different meanings. E.g A new complex number given
the (x,y) values or the (modulus,angle) values.
>> So, ES6 will likely still only provide partial *support* for classes,
>> while still allowing full *implementation* of classes as before.
>
>What would be full *support* for classes. Isn't multiple inheritance an
>important concept, for instance, which is only supported by very few
>languages? What about multiple dispatch?
Full support for classes needn't include inheritance : you can have
classes with or without inheritance and I'm concentrating on classes.
Full support would include creating the new object's properties,
presumably holding a default value such as undefined. This would also
mean that the property names are listed in the class description, as
they should be.
And wouldn't it be nice if you could write x instead of this.x inside
methods.
John