Page 1 of 1

Document "*" use in Structure Pointers

Posted: Thu Feb 03, 2011 7:24 pm
by swhite
Hi

In a structure the "*" is used to defined a pointer in a structure but it is not used to reference the structure field later. I discovered this by accident when I tried something like myStruct\*myPointer\myValue and the compiler complained. I just assumed from the documentation that since the "*" was part of the variable name it would also be part of the structure field name.

Thanks,
Simon

Re: Document "*" use in Structure Pointers

Posted: Mon Aug 12, 2013 10:35 am
by c4s
You might get used to it but it's still one of the most irritating things when dealing with structures, so: +1

Why wasn't this changed long time ago anyway? Fear of breaking backward compatibility? Well, with each release of PB there is always something improving on the syntax side and a couple of simple search'n'replaces should do it, right?!

Re: Document "*" use in Structure Pointers

Posted: Mon Aug 12, 2013 11:03 am
by luis
Was requested to be documented and now is marked as [Done], so this should be marked the same way I suppose.

http://www.purebasic.fr/english/viewtop ... 37&t=52059

And this is the snippet that was added in the doc. This also answer your question.
When using pointers in structures, the '*' has to be omitted when using the field, once more to ease API code porting. It can be seen as an oddity (and to be honest, it is) but it's like that since the very start of PureBasic and many, many sources rely on that so it won't be changed.
Even with this "hint" I still don't understand why it was so in the first place, but that's another story.

Re: Document "*" use in Structure Pointers

Posted: Mon Aug 12, 2013 11:54 am
by c4s
Oh sorry, I overread the "document" in the thread title. I +1'ed to change the syntax accordingly...