News for hackers. Stuff that matters.

A new kind of inheritance in programming languages?

Hi, I may have discovered a new kind of inheritance while building my product, its called deep inheritance and it allows for much more contextual information.

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...

( 4 comments | 10 points | on HN )
Re:A new kind of inheritance in programming languages? by onaclov2000 on Tuesday July 16, 2013 @07:08AM (#6051029)
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.
Re:A new kind of inheritance in programming languages? by SparK-Cruz on Tuesday July 16, 2013 @08:31AM (#6051399)
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.

Re:A new kind of inheritance in programming languages? by benji-york on Tuesday July 16, 2013 @12:53PM (#6053068)
This is called Acquisition. See http://c2.com/cgi/wiki?AcquisitionInheritance
Re:A new kind of inheritance in programming languages? by rivd on Tuesday July 16, 2013 @01:25PM (#6053294)
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 ?