Will D 2.x have refrences

BLS nanali at nospam-wanadoo.fr
Thu Oct 11 22:32:26 PDT 2007


Jari-Matti Mäkelä schrieb:
> Bill Baxter wrote:
> 
>> But they don't work for things that require '.'s to get to.
>>
>> void main() {
>>     int& value = myClass.some.value_member; // C++, ok
>>     ...
>> }
>>
>> void main() {
>>     alias myClass.some.value_member  value;  // D, ack!
>> }
>>
> 
> Hmm, interesting. Wouldn't it be possible to extend the functionality?
> Doesn't seem like alias fully handles those as symbols. For example this
> gives me two(?!) "Error: need 'this' for address of bar" errors on the last
> line:
> 
> struct foo {
>   struct b { int a; }
>   b bar;
> }
> 
> foo f;
> alias f.bar b;
> assert(b.a == 0);

Yes, I also would like to see extended alias functionality too.
...having  alias  instead of  & for refrences will make D more readable.
I especially don't like the double and triple meanings of symbols. Is * 
used as  pointer, as dereference, as mul operator ?
Same is valid for &   refrence or address of ?
Sure, the context will show it, but I prefer "p IS POINTER TO" style 
languages
D should be more reliable the C++, guess you know what I mean.
Bjoern
Bjoern



More information about the Digitalmars-d mailing list