It is currently Wed Aug 21, 2019 2:12 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Module use of '*' for pointer variables feels weird
PostPosted: Sat Jul 14, 2018 4:10 am 
Offline
Addict
Addict
User avatar

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3237
After becoming so used to leaving the '*' off when accessing structure members, this feels really weird for modules:

Code:
DeclareModule TestModule
  *Pointer=0
EndDeclareModule

Module TestModule
EndModule

Structure TestStruct
  *Pointer
EndStructure

Define TestStruct.TestStruct

Debug TestModule::*Pointer
Debug TestStruct\Pointer

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Module use of '*' for pointer variables feels weird
PostPosted: Sat Jul 14, 2018 4:36 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 880
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Module use of '*' for pointer variables feels weird
PostPosted: Sat Jul 14, 2018 4:41 am 
Offline
Addict
Addict
User avatar

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3237
I guess this works. I've never tried it before:

Code:
*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.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Module use of '*' for pointer variables feels weird
PostPosted: Sat Jul 14, 2018 5:11 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye