digitalmars.D - Will D 2.x have refrences
- BLS (11/11) Oct 10 2007 I mean something comparable to :
- Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= (10/22) Oct 11 2007 void main() {
- Bill Baxter (10/37) Oct 11 2007 But they don't work for things that require '.'s to get to.
- Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= (12/23) Oct 11 2007 Hmm, interesting. Wouldn't it be possible to extend the functionality?
- Bill Baxter (6/33) Oct 11 2007 Seems like it should be possible to make it work. There was some talk
- BLS (11/38) Oct 11 2007 Yes, I also would like to see extended alias functionality too.
- BLS (3/30) Oct 11 2007 Thanks Jari, I simply did not know about that feature. (ashamed)
- Bill Baxter (7/19) Oct 11 2007 I posted a list of three things that D doesn't have that make life a lot...
- BLS (5/27) Oct 11 2007 Let's hope "we'll get all of those". Unfortunately Walter is comming up
- Frits van Bommel (2/5) Oct 11 2007 Some "unsurprising" (i.e. oft-requested) new features would be nice too ...
I mean something comparable to : //C++ int value = 100; int & rIntRef = value; if (rIntRef == 100) // be ashured my val is 100 rIntref = 101 if (&rIntref == &value) // Yes we have the same address (not parameter passing) Bjoern
Oct 10 2007
BLS wrote:I mean something comparable to : //C++ int value = 100; int & rIntRef = value; if (rIntRef == 100) // be ashured my val is 100 rIntref = 101 if (&rIntref == &value) // Yes we have the same address (not parameter passing) Bjoernvoid main() { int value = 100; alias value rIntRef; if (rIntRef == 100) rIntRef = 101; assert(value == 101); assert(&value == &rIntRef); } Alias parameters also work in functions wrapped inside templates.
Oct 11 2007
Jari-Matti Mäkelä wrote:BLS 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! } --bbI mean something comparable to : //C++ int value = 100; int & rIntRef = value; if (rIntRef == 100) // be ashured my val is 100 rIntref = 101 if (&rIntref == &value) // Yes we have the same address (not parameter passing) Bjoernvoid main() { int value = 100; alias value rIntRef; if (rIntRef == 100) rIntRef = 101; assert(value == 101); assert(&value == &rIntRef); } Alias parameters also work in functions wrapped inside templates.
Oct 11 2007
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);
Oct 11 2007
Jari-Matti Mäkelä wrote:Bill Baxter wrote: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;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);Yeh, the error messages don't make much sense. I think I've seen that one a lot.
Oct 11 2007
Jari-Matti Mäkelä schrieb:Bill Baxter wrote: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 BjoernBut 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);
Oct 11 2007
Jari-Matti Mäkelä schrieb:BLS wrote:Thanks Jari, I simply did not know about that feature. (ashamed) BjoernI mean something comparable to : //C++ int value = 100; int & rIntRef = value; if (rIntRef == 100) // be ashured my val is 100 rIntref = 101 if (&rIntref == &value) // Yes we have the same address (not parameter passing) Bjoernvoid main() { int value = 100; alias value rIntRef; if (rIntRef == 100) rIntRef = 101; assert(value == 101); assert(&value == &rIntRef); } Alias parameters also work in functions wrapped inside templates.
Oct 11 2007
BLS wrote:I mean something comparable to : //C++ int value = 100; int & rIntRef = value; if (rIntRef == 100) // be ashured my val is 100 rIntref = 101 if (&rIntref == &value) // Yes we have the same address (not parameter passing) BjoernI posted a list of three things that D doesn't have that make life a lot easier in C++. One of them was returning references from functions. Walter's response was "D will get all of those". Now it may be a really long time before they come to pass, and Walter may change his mind, but at least at one point he said references would become returnable. --bb
Oct 11 2007
Bill Baxter schrieb:BLS wrote:Let's hope "we'll get all of those". Unfortunately Walter is comming up with surprising new featues all the time... which is nice but, frankly said, I would prefer a straight milestone roadmap. BjoernI mean something comparable to : //C++ int value = 100; int & rIntRef = value; if (rIntRef == 100) // be ashured my val is 100 rIntref = 101 if (&rIntref == &value) // Yes we have the same address (not parameter passing) BjoernI posted a list of three things that D doesn't have that make life a lot easier in C++. One of them was returning references from functions. Walter's response was "D will get all of those". Now it may be a really long time before they come to pass, and Walter may change his mind, but at least at one point he said references would become returnable. --bb
Oct 11 2007
BLS wrote:Let's hope "we'll get all of those". Unfortunately Walter is comming up with surprising new featues all the time... which is nice but, frankly said, I would prefer a straight milestone roadmap.Some "unsurprising" (i.e. oft-requested) new features would be nice too :P.
Oct 11 2007