moveAt vs opIndex

Jonathan M Davis jmdavisProg at gmx.com
Mon May 21 00:50:52 PDT 2012


On Saturday, May 19, 2012 17:28:46 maarten van damme wrote:
> and something partially unrelated, how do you copy a class by value?

You don't. If the class has a clone method (which would fairly typically be 
called dup in D), then you can clone it, but classes are reference types, not 
value types.

In general, it makes little sense to use a class to implement a range. You 
more or less never need polymorphism, and in most cases, using a struct which 
saves which is saved when you create a new struct from it works really well 
and is exactly what you want. If you you use classes, then you're more likely 
to run into issues with missed calls to save and the like. In general, it just 
doesn't make sense to use classes for ranges, and there has periodicaly been 
talk of not really supporting it (though that isn't likely to happen).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list