Module use of '*' for pointer variables feels weird

Everything else that doesn't fall into one of the other PB categories.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Module use of '*' for pointer variables feels weird

Post by Mistrel »

After becoming so used to leaving the '*' off when accessing structure members, this feels really weird for modules:

Code: Select all

DeclareModule TestModule
  *Pointer=0
EndDeclareModule

Module TestModule
EndModule

Structure TestStruct
  *Pointer
EndStructure

Define TestStruct.TestStruct

Debug TestModule::*Pointer
Debug TestStruct\Pointer
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Module use of '*' for pointer variables feels weird

Post by Josh »

The fact that the asterisk is not used in structures is a mistake that goes back to the beginnings of Pure-Basic. But this is not a reason that this 'bug' should be repeated with newly introduced features.
sorry for my bad english
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Module use of '*' for pointer variables feels weird

Post by Mistrel »

I guess this works. I've never tried it before:

Code: Select all

*a=1
a=2

Debug *a
Debug a
I see why they did it since modules are more like namespaces and the variable name will have the asterisk when brought into scope. I was just caught a little by surprise.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Module use of '*' for pointer variables feels weird

Post by Dude »

The asterisk character can be used as part of a variable name (at the start). So you can literally have a, *a, _a, and a$, and all four will be different variables.
Post Reply