digitalmars.D.learn - What about C's -> ?
- Hoenir (2/2) Jul 24 2007 There seems to be no p->x in D. Is there any other syntactic sugar for
- freeagle (2/4) Jul 24 2007 dot operator stands for both dot and -> operators in c++
- Bill Baxter (5/10) Jul 24 2007 Just curious -- does it also work for (**p).x and (***p).x etc?
- Chris Nicholson-Sauls (7/19) Jul 24 2007 As far as I recall, yes. The '.' will "continuously" dereference until
- freeagle (17/17) Jul 24 2007 nope, it does not:
- Chris Nicholson-Sauls (7/30) Jul 24 2007 Well I'll be darned. :)
- Jason House (9/32) Jul 25 2007 pppa.a -> fails
- freeagle (4/4) Jul 24 2007 btw, you can find good tutorials at http://www.dsource.org and
There seems to be no p->x in D. Is there any other syntactic sugar for (*p).x ?
Jul 24 2007
Hoenir wrote:There seems to be no p->x in D. Is there any other syntactic sugar for (*p).x ?dot operator stands for both dot and -> operators in c++
Jul 24 2007
freeagle wrote:Hoenir wrote:Just curious -- does it also work for (**p).x and (***p).x etc? (Sorry to lazy to check :-P ) But surely someone here knows right off the top of their head. --bbThere seems to be no p->x in D. Is there any other syntactic sugar for (*p).x ?dot operator stands for both dot and -> operators in c++
Jul 24 2007
Bill Baxter wrote:freeagle wrote:As far as I recall, yes. The '.' will "continuously" dereference until it hits something solid, and then offset appropriately from there. Although I rarely have had more than (*p) in my experience with D. (And usually only with referencing elements from arrays of structures, and with using the 'in' operator on associative arrays.) -- Chris Nicholson-SaulsHoenir wrote:Just curious -- does it also work for (**p).x and (***p).x etc? (Sorry to lazy to check :-P ) But surely someone here knows right off the top of their head. --bbThere seems to be no p->x in D. Is there any other syntactic sugar for (*p).x ?dot operator stands for both dot and -> operators in c++
Jul 24 2007
nope, it does not: import tango.io.Stdout; class Test { int a; } int main(char[][] args) { Test a = new Test(); a.a = 13123; Test* pa = &a; Test** ppa = &pa; Test*** pppa = &ppa; Stdout(pppa.a).newline; return 0; } test.d(16): Error: no property 'a' for type 'Test**'
Jul 24 2007
freeagle wrote:nope, it does not: import tango.io.Stdout; class Test { int a; } int main(char[][] args) { Test a = new Test(); a.a = 13123; Test* pa = &a; Test** ppa = &pa; Test*** pppa = &ppa; Stdout(pppa.a).newline; return 0; } test.d(16): Error: no property 'a' for type 'Test**'Well I'll be darned. :) If this usage is actually cropping up, then I guess there ought to be a feature request put in for it. (In hand tooled code, its no big issue just to partially dereference in place, but in generic code from templates, mixins, what have you, this could potentially be hazardous.) -- Christopher Nicholson-Sauls
Jul 24 2007
freeagle wrote:nope, it does not: import tango.io.Stdout; class Test { int a; } int main(char[][] args) { Test a = new Test(); a.a = 13123; Test* pa = &a; Test** ppa = &pa; Test*** pppa = &ppa; Stdout(pppa.a).newline; return 0; } test.d(16): Error: no property 'a' for type 'Test**'pppa.a -> fails test.d(16): Error: no property 'a' for type 'Test**' pppa...a -> fails test.d(16): found '...' when expecting ',' pppa. . .a -> fails test.d(16): identifier expected following '.', not '.' (**pppa).a -> works (***pppa).a -> works
Jul 25 2007
btw, you can find good tutorials at http://www.dsource.org and http://www.prowiki.org/wiki4d/wiki.cgi?FrontPage that will answer most of your questions. And if you need something more specific ( but a bit less understandable ), look at D's homepage for language specifications
Jul 24 2007