'::' Global Namespace To Avoid Name Collision With PB

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

'::' Global Namespace To Avoid Name Collision With PB

Post by grabiller »

Hello,

It could be very usefull to have an option to have all the PureBasic exposed constants, prototypes, etc.. accesssible only under the 'Global' namespace '::'.

For instance to access the #Red constant - with this option activated - we would use:

Code: Select all

Debug ::#Red
The reason for this is that while Modules are great to avoid collisions from user generated code, it does not prevent collision with PureBasic exposed items (when importing libraries, for instance).

Cheers,
Guy.
guy rabiller | radfac founder / ceo | raafal.org
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: '::' Global Namespace To Avoid Name Collision With PB

Post by luis »

What freak wrote here -> http://www.purebasic.fr/english/viewtop ... 10#p403210 makes me think this is not going to happen.
When a collision with something PB-defined happens, PB win.

A global namespace to access everything external to modules is what many (ok, some) of us have asked but this is not going to happen neither (even if you can already access foreign data from a module using another module, showing how the idea of total encapsulation in a module is unsound and to fight it is just counter productive).

This is what I suggested at the time when modules were still being discussed and not yet implemented -> http://www.purebasic.fr/english/viewtop ... 30#p403130

With the :: you don't need any option, which would cause just more problems. Things internal to the module come first for the module and that's that.
To access the unnamed global module (namespace) you just use ::

I'm pretty sure this is only academic chatter now, unfortunately.
I find this an error in judgement, which crippled the module concept in real life forcing you to use silly convoluted ways trying to go around it.
I mentioned this thing in my small PB review linked below too.
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply