subclassing

spir denis.spir at gmail.com
Tue Nov 2 08:17:54 PDT 2010


On Tue, 02 Nov 2010 10:39:27 -0400
Jesse Phillips <jessekphillips+D at gmail.com> wrote:

> I'll come back with a more complete answer latter, but first.
> 
> spir Wrote:
> 
> > * I wrote Range as class, but I rather meant an interface. D does not let me do that, apparently because there is no data slot in a D interface. Is then an interface a kind of data-less superclass? Or is there something I misunderstand?
> 
> Interfaces describe what can something of that type can do, not what it has. Data fields are not allowed only function signatures and functions that perform local modifications.

Thank you for the clarification.

> > 	auto range = ...;
> > 	while (range.continues) {
> > 		doSomethingWith(range.element);
> > 		range.step();
> > 	}
> 
> Note that you are not actually using a Range as it is defined by D.

Yes, that's precisely what I meant with "experimenting around this notion" [of range].


Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d-learn mailing list