4 ms·
If that is the only use case I would rather want another solution to keep the language minimal. Just like the garbage collection was moved to a library.
by jeltz 13y ago
If that is the only use case I would rather want another solution to keep the language minimal. Just like the garbage collection was moved to a library.
- dbaupp 13y agoI think that the core team thought about this long and hard, but it was decided that there was no other solution. A virtual method call to look up some property shared by all the DOM nodes was just too expensive: a constant offset field look up is far far faster.
- pcwalton 13y agoCan't really do it. I tried. The type checker just plain has to know about inheritance for it to work and be safe. The good news is that's an extremely constrained sort of inheritance, very unlike traditional OO in that it doesn't have base classes--it's just a special extension to the trait (typeclass) system that allows you to require that structs begin with a certain set of fields. In fact, I don't even call it inheritance these days--I prefer the name "structural constraints".
- thirsteh 13y agoI think this is a good idea. It seems similar to Go's embedding: http://golang.org/doc/effective_go.html#embedding http://golang.org/doc/effective_go.html#embedding
- carterschonwald 13y agoooh, is this like record subtyping? Have you seen ermine https://github.com/ermine-language https://github.com/ermine-language or Ur/web? http://www.impredicative.com/ur/ http://www.impredicative.com/ur/ [edit, on #rust it was explained to me that its only for pointers to structs, but thats fine by me]
- dbaupp 13y agoIf anyone is interested, the proposal for Rust is detailed in http://smallcultfollowing.com/babysteps/blog/2013/10/24/single-inheritance/ http://smallcultfollowing.com/babysteps/blog/2013/10/24/sing...
- jeltz 13y agoThanks for the answer, and I think I like your solution to the problem.