Will D 2.x have refrences

Bill Baxter dnewsgroup at billbaxter.com
Thu Oct 11 17:41:37 PDT 2007


Jari-Matti Mäkelä wrote:
> 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?

Seems like it should be possible to make it work.  There was some talk 
previously about extending alias to work on (constant?) expressions too. 
  So you could do something like   alias Pi/2 half_pi;

> 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);

Yeh, the error messages don't make much sense.  I think I've seen that 
one a lot.



More information about the Digitalmars-d mailing list