Page 1 of 1

Module use of '*' for pointer variables feels weird

Posted: Sat Jul 14, 2018 4:10 am
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

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

Posted: Sat Jul 14, 2018 4:36 am
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.

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

Posted: Sat Jul 14, 2018 4:41 am
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.

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

Posted: Sat Jul 14, 2018 5:11 am
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.