3 ms·
Can'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 constra
by pcwalton 13y ago
Can'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.