Btw., in a typical language supporting prototypes, I would expect that prototypes are nothing special. Every object could be a prototype for others...
Prototypes Are Not Classes
11–20 of 46 posts
Re: Prototypes Are Not Classes
#12Earlier quoted context omitted.
I'm not sure that's a good idea, because then they'd be made very sad by constructors, by prototypes being something completely different[0], by not having mixins[1], by single-inheritance, by dynamic inheritance[2], by the lack of blocks (and non-local returns), etc… Essentially, by javascript not being a very good Self. [0] IIRC in Self the prototype is the object you copy, objects linked through parent slots are e…
MI still sends shivers down my spine, having spent time in the C++. Just say no.
Re: Prototypes Are Not Classes
#13Re: Prototypes Are Not Classes
#14Re: Prototypes Are Not Classes
#15Jesus, the language is called Smalltalk. Not SmallTalk. Btw., in a typical language supporting prototypes, I would expect that prototypes are nothing special. Every object could be a prototype for others...
There is a problem with accessing prototypes of objects, as they are not exposed to the user and only available through internal property __prototype__ (IIRC). And there's quite a bit of magic involved with constructor prototypes, which - again - makes it impossible to traverse prototype chain unless you create your objects yourself and store the references yourself.
So yeah, prototypes are nothing special in JS, but their API kind of sucks and could get better. Object.create is a step in the right direction IMO.
Re: Prototypes Are Not Classes
#16Earlier quoted context omitted.
MI still sends shivers down my spine, having spent time in the C++. Just say no.
So C++ got multiple inheritance wrong... That doesn't mean it must be rejected in all cases.
Re: Prototypes Are Not Classes
#17Jesus, the language is called Smalltalk. Not SmallTalk. Btw., in a typical language supporting prototypes, I would expect that prototypes are nothing special. Every object could be a prototype for others...
That's true in JavaScript - there's an Object.create() method, which creates new object with any other object set as prototype: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... There is a problem with accessing prototypes of objects, as they are not exposed to the user and only available through internal property __prototype__ (IIRC). And there's quite a bit of magic involved with constructor prototype…
Actually, Object.getPrototypeOf was added in ECMAScript 5.1. It's even supported by IE9.
> only available through internal property __prototype__ (IIRC)
It's an external property (the internal one is `[[Prototype]]`_, and is called `__proto__`. It's non-standard, although all modern browsers implement it (even IE11, but not IE10)
Re: Prototypes Are Not Classes
#18I guess before learning JavaScript, developers need to be sent to a Self learning camp.
I'm not sure that's a good idea, because then they'd be made very sad by constructors, by prototypes being something completely different[0], by not having mixins[1], by single-inheritance, by dynamic inheritance[2], by the lack of blocks (and non-local returns), etc… Essentially, by javascript not being a very good Self. [0] IIRC in Self the prototype is the object you copy, objects linked through parent slots are e…
Re: Prototypes Are Not Classes
#19Earlier quoted context omitted.
So C++ got multiple inheritance wrong... That doesn't mean it must be rejected in all cases.
What are the cases where MI is better than mix-ins or component architectures?
However Eiffel, OCaml and Python MI implementations seem to be implemented in a more sane way.
Re: Prototypes Are Not Classes
#20Jesus, the language is called Smalltalk. Not SmallTalk. Btw., in a typical language supporting prototypes, I would expect that prototypes are nothing special. Every object could be a prototype for others...