[rust-dev] Proposal: rename sequence concatenation operator to ++

Niko Matsakis niko at alum.mit.edu
Wed Jan 25 14:23:49 PST 2012


On 1/25/12 12:18 PM, Marijn Haverbeke wrote:
> That works, but doesn't provide the conceptual simplicity of a number
> interface, and if you want to write a generic over any numeric type,
> it could end up taking a<T: add, mult, sub, div>  type parameter.

It seems to me that if impls did not have to declare the interfaces 
which they implement (as I would prefer), then we could simply declare 
several interfaces (addable, divable, num) and things would just work.  
Some interfaces, like num, could be a superset of others.   This would 
be an alternative to introducing subtyping into interfaces.  Not that 
I'm opposed to that per se, but it's more than we need to solve this case.

One situation which would be improved through some sort of inheritance:

     fn foo<A: add>(x: A) { ... }
     fn bar<N: num>(x: N) {
         foo(x);
     }

This call ought to work, as num is a superset of add, but we'd need to 
construct a "derived vtable" of some sort which means that we'd get 
another layer of indirection at runtime.  Kind of a drag.



Niko


More information about the Rust-dev mailing list