iterators again

Bill Baxter dnewsgroup at billbaxter.com
Sun May 27 20:39:00 PDT 2007


David B. Held wrote:
> Bill Baxter wrote:
>> [...]
>> And classes don't have fully useful copy c'tors either, so you can't 
>> really hold that against structs.
> 
> Classes have reference semantics, so you need to implement a clone() 
> method if you want deep copies.  Value types need to support 
> copy/assign/swap as first-class operations.

Ok, the way you said it before made it sound like you were arguing 
structs were no good for iterators because they can't do anything more 
than a bitwise copy.  But you were actually saying classes are no good 
for iterators because they can't be given value semantics.  Gotcha.

>> [...]
>> The only think I've thought of (and this is probably Tango's main 
>> justification for classes) is that structs can't inherit.
> 
> There is some talk about allowing structs to implement interfaces, but 
> that is a technically non-trivial change.

I'm struggling here.  I'm feeling the void when it comes to iterators in 
D, but none of the solutions I've seen implemented really resonate with 
me.  I'm not sure whether it's me, or the libraries, or D that need to 
change.  But I like my iterators to be value types, darnit.  :-)

--bb



More information about the Digitalmars-d mailing list