Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-28 Thread Andrew Godfrey via Digitalmars-d-learn
On Friday, 29 August 2014 at 02:10:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: In D you just use '.' throughout and it Just Works(tm). Unless the property you're accessing is also a pointer property, like sizeof. Then you have to be careful. The below prints 4 then 8 (on 32-bit):

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-28 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 29, 2014 at 04:37:37AM +, Andrew Godfrey via Digitalmars-d-learn wrote: On Friday, 29 August 2014 at 02:10:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: In D you just use '.' throughout and it Just Works(tm). Unless the property you're accessing is also a pointer

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-28 Thread Andrew Godfrey via Digitalmars-d-learn
On Friday, 29 August 2014 at 05:05:55 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, Aug 29, 2014 at 04:37:37AM +, Andrew Godfrey via Digitalmars-d-learn wrote: Unless the property you're accessing is also a pointer property, like sizeof. Then you have to be careful. True. Though

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-28 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 29, 2014 at 05:28:12AM +, Andrew Godfrey via Digitalmars-d-learn wrote: On Friday, 29 August 2014 at 05:05:55 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, Aug 29, 2014 at 04:37:37AM +, Andrew Godfrey via Digitalmars-d-learn wrote: Unless the property you're

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-28 Thread Ali Çehreli via Digitalmars-d-learn
On 08/28/2014 09:37 PM, Andrew Godfrey wrote: On Friday, 29 August 2014 at 02:10:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: In D you just use '.' throughout and it Just Works(tm). Unless the property you're accessing is also a pointer property, like sizeof. Then you have to be

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-27 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 27, 2014 at 07:25:41PM +, Gary Willoughby via Digitalmars-d-learn wrote: This is something that has been on my mind since i discovered this the other day. Does D provide automatic dereferencing for accessing members through pointers? [...] Yes it does. This is particularly

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-27 Thread Brian Schott via Digitalmars-d-learn
On Wednesday, 27 August 2014 at 19:25:42 UTC, Gary Willoughby wrote: Why don't you need to dereference the pointer 'foo' to reach its member 'bar'? The compiler inserts the dereference for you. (It knows which types are references and which are values and can do this correctly) This makes

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-27 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 27 August 2014 at 19:36:08 UTC, Brian Schott wrote: On Wednesday, 27 August 2014 at 19:25:42 UTC, Gary Willoughby wrote: Why don't you need to dereference the pointer 'foo' to reach its member 'bar'? The compiler inserts the dereference for you. (It knows which types are

Re: Does D provide automatic dereferencing for accessing members through pointers?

2014-08-27 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 27 August 2014 at 19:25:42 UTC, Gary Willoughby wrote: I've taken a look in the std lib and the second form is used a lot. Why don't you need to dereference the pointer 'foo' to reach its member 'bar'? Walter didn't want foo-bar so we have foo.bar