Re: [rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-27 Thread Lionel Parreaux
I see. Thanks for the links, Greg Morrisett's notes are a great survey of possible approaches to this problem. It is funny because I had also come to the conclusion that JIT was the neater solution, as long as JIT is available with the runtime... and you don't have to implement it -- I guess it's

Re: [rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-25 Thread Patrick Walton
On 7/25/14 8:26 PM, Patrick Walton wrote: Uniform value representations work well too (as OCaml shows), but of course you'll pay a performance cost for that. Oh, note that Greg's notes are a little bit out of date when discussing the performance tradeoffs of uniform value representation. On

Re: [rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-24 Thread Lionel Parreaux
Hi, Could you provide a link to Patrick's description of size/alignment-passing implementation? I'm interested in these things. Well, there could be a warning if the compiler switches to such an implementation. It's arguably still better than not compiling at all. However, I don't have enough

Re: [rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-24 Thread Daniel Micay
On 24/07/14 11:59 AM, Lionel Parreaux wrote: I can't pronounce myself about the suitability of features in the Rust language, but it may be worth noting that some convenient high-level features are already present in the language, like garbage collection. There isn't an implementation of

[rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-22 Thread Lionel Parreaux
Hi, So traits seem to be quite similar to Haskell's classes, being also used for parametric polymorphism. Now, Haskell classes are usually implemented using runtime dictionary passing. In general, code cannot be specialized for every function call, since there may be an unbounded number of

Re: [rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-22 Thread Corey Richardson
You can avoid monomorphization by using trait objects, which erase the precise implementing type through a vtable + pointer. http://doc.rust-lang.org/tutorial.html#trait-objects-and-dynamic-method-dispatch has some documentation. On Tue, Jul 22, 2014 at 10:16 AM, Lionel Parreaux

Re: [rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-22 Thread Nawfel BGH
this remindes me of the issue i got when trying to implement finger trees in Rust so long ago https://github.com/rust-lang/rust/issues/8613 I suggested to let add a way to specify (in the code) how match functions do we want to generate and failing at runtime when the limit is reached. This made

Re: [rust-dev] Implementation of traits in Rust: could it be dynamic?

2014-07-22 Thread Patrick Walton
On 7/22/14 10:16 AM, Lionel Parreaux wrote: I'm not sure whether this is a big problem in practice, but I was wondering if it would be possible to switch to some runtime mechanism in cases like this. Maybe we could make a special version of every generic functions, that takes a dictionary at