A new kind of inheritance in programming languages?
3 comments
I've actually had similar thoughts about this, basically an objects becomes another object based on context, in your case you're "adding" elements to the object, however I had been thinking that just simply creating a bunch of objects with different properties, and whenever it is in a state that it can become that object (due to an action on it), it automatically is typecast to that type of object and referred to as that from there forward, I've never tried it, but it was just a thought. Interesting read.
You are not inheriting behaviour, you are inheriting values of a list.
You could simply instanciate a new object of the child type, access the parent type attributes and set it to the child.
This could also work with a constructor or a valueOf method.
If you are looking for dynamic languages, see JavaScript and Ruby.
If you are looking for dynamic languages, see JavaScript and Ruby.
This is called Acquisition. See http://c2.com/cgi/wiki?AcquisitionInheritance
the c2 article speaks of the difference between dynamic scoping and acquisition as the former being dependent on call context and the latter on "where you put it".
Can i conclude acquisition can be done in javascript by binding function objects ?
var fn = somefunc.bind(other_object)
Or is this still dynamic scoping because it only sets the value of this for fn ?
Can i conclude acquisition can be done in javascript by binding function objects ?
var fn = somefunc.bind(other_object)
Or is this still dynamic scoping because it only sets the value of this for fn ?
Its hard to explain, its described here: http://www.solebase.com/psychological-basis.html
Tell me, is it as useful as I think it is? Is it unique? Or is it only useful in theory?
I'm curious about your answers...