Double Colon use in Purebasic

Everything else that doesn't fall into one of the other PB categories.
swhite
Enthusiast
Enthusiast
Posts: 727
Joined: Thu May 21, 2009 6:56 pm

Double Colon use in Purebasic

Post by swhite »

Hi

I have seen some Purebasic code on the ChilKat Software website that uses "::" (double colons). In other languages I have seen this used for a scope resolution operator and it looks like that in the Purebasic code but I cannot find any documentation about the use of double colons in Purebasic. Does anyone know where I can find some information about the use of the double colon in reference to Purebasic?

Thanks,
Simon
Simon White
dCipher Computing
User avatar
skywalk
Addict
Addict
Posts: 3999
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Double Colon use in Purebasic

Post by skywalk »

True, it should be mentioned in the general syntax rules. But '::' is shown in modules.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Double Colon use in Purebasic

Post by netmaestro »

With modules all of the procedures and vars specific to the module are only visible within the module. Basically, anywhere else you might be within the code, be it the main code or inside a procedure, module assets are "out of scope" to you. This is of course by design. But you need to use what's in modules from time to time and so there are two ways to do that from foreign codeparts:

1) UseModule Stuff This will make assets from the module "Stuff" visible to your current location without further qualification.

2) You can tap the module assets without UseModule by qualifying their names with the module name followed by the :: symbol. Stuff::<asset name> allows this.

Also note that this addition occasioned some changes in PB syntax with regard to colons. For example, this used to be allowed:

DataSection
label1: IncludeBinary "Somefile"
EndDataSection

but now it will generate a syntax error. It was always a shortcut that broke basic syntax rules anyway, it just took the new :: addition turning up for it to come under the piercing glare of Fred's evil eye, where it did not survive for long.
BERESHEIT
Post Reply