iterators again

Bruno Medeiros brunodomedeiros+spam at com.gmail
Wed Jun 6 05:11:22 PDT 2007


David B. Held wrote:
> Bruno Medeiros wrote:
>> [...]
>> So
>>   typeof(foo) is:  final Foo
>> but
>>   typeof(*(&foo)) is:  const(Foo)
>> which seems a breach in orthogonality, and meaning that this won't be 
>> allowed:
>>   (*(&foo)).membervar = 42;
> 
> Can you produce a realistic scenario where you need to take a pointer to 
> a final and get back the exact type?  Most of the time, you shouldn't 
> even need to take addresses in D.  Most uses of pointers is with dynamic 
> allocation.
> 
> Dave

Well, I wasn't saying that this is a terrible problem, for now I was 
just confirming if this indeed happens with the planned design.

Still, I do have a feeling that it might cause some problems, altough I 
can't think of any concrete scenario right now (which doesn't mean there 
is one). For example, advanced type-generic templates usually get more 
complicated because of special and nonorthogonal cases. I've heard 
people say they had some inconveniences (don't know how severe they were 
though) because typeof(T) == typeof(T.init) is true for all types, 
*except* static arrays.
Similarly, problems might arise because:
   typeof(*(&something)) == typeof(something)
is true for all vars, except those that are final.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list