News for hackers. Stuff that matters.
Re:Rust 0.9 released by pcwalton on Thursday January 09, 2014 @08:16PM (#7034431)
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".

Re:Rust 0.9 released by carterschonwald on Thursday January 09, 2014 @09:43PM (#7034793)
ooh, is this like record subtyping? Have you seen ermine https://github.com/ermine-language or Ur/web? 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]

Re:Rust 0.9 released by dbaupp on Thursday January 09, 2014 @10:16PM (#7034892)
If anyone is interested, the proposal for Rust is detailed in http://smallcultfollowing.com/babysteps/blog/2013/10/24/sing...
Re:Rust 0.9 released by thirsteh on Thursday January 09, 2014 @09:10PM (#7034649)
I think this is a good idea. It seems similar to Go's embedding: http://golang.org/doc/effective_go.html#embedding
Re:Rust 0.9 released by pcwalton on Thursday January 09, 2014 @09:15PM (#7034667)
The difference is that the base struct can call methods on the derived struct, whereas this is not possible with that kind of struct embedding. This is important for some use cases (e.g. the DOM or the render tree).
Re:Rust 0.9 released by thirsteh on Thursday January 09, 2014 @09:26PM (#7034718)
I see.
Re:Rust 0.9 released by jeltz on Thursday January 09, 2014 @11:12PM (#7035060)
Thanks for the answer, and I think I like your solution to the problem.