[5.10] Native types can't be used with pointers

Just starting out? Need help? Post your questions and find answers here.
User avatar
IceSoft
Addict
Addict
Posts: 1682
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: [5.10] Native types can't be used with pointers

Post by IceSoft »

luis wrote:
Psychophanta wrote: Native types really STILL CAN BE USED with pointers.
since this is probably due to the fact PB doesn't check by design for an existing definition of a structure when one is referenced using pointers inside a structure.
Where is this statement?
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Psychophanta »

@luis, Sorry but you seem to talk about other things.
What i am referring to is other issue. Check the title of this thread please.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: [5.10] Native types can't be used with pointers

Post by PMV »

Psychophanta wrote:Requested for years about this needed fixation for consistence and readability, and finally here it is.

However, there is still the buggy feature:
Native types really STILL CAN BE USED with pointers.
Look & see:

Code: Select all

Structure so
  *locationinmem.b; <- ??
EndStructure
f.so\locationinmem=78

Debug f\locationinmem
I have not installed PB 5.10 here, so can't check if this really works.
But if that is the case as you write, please make a bug-report :)

MFG PMV
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.10] Native types can't be used with pointers

Post by luis »

IceSoft wrote:Where is this statement?
No idea, probably nowhere. Just try it:

Code: Select all

Structure mela
 item.pera ; not allowed
EndStructure

Code: Select all

Structure mela
 *item.pera ; allowed
EndStructure
Psychophanta wrote:@luis, Sorry but you seem to talk about other things.
What i am referring to is other issue.
What are you referring to then ?
Haven't you defined a pointer to a native type (now forbidden) inside a structure ?
If so, I'm talking about the same thing.
Psychophanta wrote: Check the title of this thread please.
Ok, wait... Done. It's the same title I was remembering. :)

You better report it but don't know if Fred will fixed it, since this is probably due to the fact PB doesn't check by design for an existing definition of a structure when one is referenced using pointers inside a structure.

Are we ok now ?
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Psychophanta »

I am full of reporting bugs and lots of them are rejected, so do report you if you want...
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.10] Native types can't be used with pointers

Post by luis »

So we are ok now and we were referring to the same thing, right ?

OK !
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Psychophanta »

luis wrote:So we are ok now and we were referring to the same thing, right ?

OK !
Tha case is that there is allowed to define pointers with native types, that's all.
If the root (cause) of it is that there is allowed to define pointers with any type, including not existing ones, it is other (still worse) thing.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.10] Native types can't be used with pointers

Post by luis »

Psychophanta wrote: If the root (cause) of it is that there is allowed to define pointers with any type, including not existing ones, it is other (still worse) thing.
It's not a bug, it's a special case by design or you couldn't do something like this:

Code: Select all

Structure t1
 *item.t2
EndStructure

Structure t2
 *item.t1   
EndStructure
An item inside a structure of type t2 could point to a structure t1, and an item inside a structure of type t1 could point to a structure t2. But if PB blocked you with an error when you were trying to define structure t1 you would be unable to describe this situation in code.

And yes, this is probably why the ability to define a pointer to a native type slipped through in this case.

Anyway, I'll do the bug report then :)
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Psychophanta »

I disagree with that "by design feature", because, even with a single compiling pass, the compiler should register (tracking) all the things it is reading, and check whether there is defined later or not...
You see what i mean?

Besides of that, why this doesn't work?. There is another inconsistence, you see?

Code: Select all

Structure t1
  item2.t2
EndStructure

Structure t2
 *item.t1   
EndStructure
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.10] Native types can't be used with pointers

Post by luis »

No, because it's generating code on the way down while it's reading the source.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Psychophanta »

luis wrote:No, because it's generating code on the way down while it's reading the source.
That is dangerous, and for sure in the future Fred will realize of it.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.10] Native types can't be used with pointers

Post by luis »

Psychophanta wrote: Besides of that, why this doesn't work?. There is another inconsistence, you see?

Code: Select all

Structure t1
  item2.t2
EndStructure

Structure t2
 *item.t1   
EndStructure
No again for the same reason above. t2 is not referenced in your case, it's part of the structure you are trying do define.
In case of the pointer, it's just a pointer, in case of the whole structure the compiler need to know the structure definition.
"Have you tried turning it off and on again ?"
A little PureBasic review
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Fred »

It's now forbidden as well (to forbid native type in pointer structure field), for consistency.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Psychophanta »

Fred wrote:It's now forbidden as well (to forbid native type in pointer structure field), for consistency.
Still, that kind of issues have a real solution in one pass compiling scheme.
I don't say to do it now, but to take in account for future would be a good thing.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: [5.10] Native types can't be used with pointers

Post by Psychophanta »

@Fred, at the moment, to give an idea to solve this, i suggest just to leave it as it is now, but just invalidating only the native types (.c , .b , etc.) for the pointers inside structures.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply