Document "*" use in Structure Pointers

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
swhite
Enthusiast
Enthusiast
Posts: 790
Joined: Thu May 21, 2009 6:56 pm

Document "*" use in Structure Pointers

Post 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
Simon White
dCipher Computing
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Document "*" use in Structure Pointers

Post 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?!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Document "*" use in Structure Pointers

Post 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.
"Have you tried turning it off and on again ?"
A little PureBasic review
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Document "*" use in Structure Pointers

Post by c4s »

Oh sorry, I overread the "document" in the thread title. I +1'ed to change the syntax accordingly...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply