byval keyword to make objects act as value types
BC
NOTmi_emayl_adrez at hotmail.com.remove.not
Sat Dec 22 18:41:15 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;
despite the name 'byval' b actually holds a reference to a copy of
Derived, so slicing is avoided.
or, if that's too inefficient perhaps the linker can figure out the size
of the largest class derived from Base and allocate that much on the
stack/inside a containing class.
myFunction(ref Base arg)
{
++arg;
}
myFunction(b)
i'm thinking it should be overridable so that the above function *does*
change the value of b
question: are calls to final class member functions non-virtual?
i notice the tango iterators are classes. surely we want to use iterators
as value types... this way, we can.
alternatively, since scope objects are a bit like value types already,
perhaps we can just add the functionality to that.
then, we just need to return refs from functions, and it's goodbye C++!
More information about the Digitalmars-d
mailing list