byval keyword to make objects act as value types

Craig Black craigblack2 at cox.net
Sat Dec 22 22:22:49 PST 2007


>so that 'byval MyClass' is a new type that acts like MyClass in all ways 
>(ie. is polymorphic) except that it gets dupped on non-const assignment 
>from other byval MyClasses and normal MyClasses. possibly also on 
>assignment to normal MyClasses. this would require that it *has* a dup 
>method, or maybe a copy constructor
>
>byval Base b = new Derived;

I'm not really "getting" your proposal, but maybe I missed something. 
What's the novelty here?  Why not just add copy semantics to structs?  Then 
you don't need the byval keyword anymore.

>i notice the tango iterators are classes. surely we want to use iterators 
>as value types... this way, we can.

I wholeheartedly agree, but why not use structs?

-Craig 




More information about the Digitalmars-d mailing list