Page 1 of 1

Modules - Optional Prefix / Suffix for UseModule

Posted: Sat Jun 29, 2013 6:27 pm
by c4s
There is a high chance that the public procedure/variable/constant names of different modules clash when using UseModule. In that situation Fred and Freak suggest to already use prefixes in the module.
In my opinion this isn't the best solution at all: In a module about e.g. animation I know what it's all about, so there is no need to call the only creation procedure "CreateAnimation()" etc. Isn't even not having to take care of unique names (which can get pretty long most times) one of the great advantages of modules?!

So why not simply introduce a straightforward "workaround"? My suggestion is an optional Prefix / Suffix parameter for UseModule. It could look like this:

Code: Select all

DeclareModule ImagePNG
  Load()
EndDeclareModule

DeclareModule ImageJPG
  Load()
EndDeclareModule

DeclareModule ImageBMP
  Load()
EndDeclareModule

UseModule ImagePNG Prefix PNG_
UseModule ImageJPG Suffix JPG
UseModule ImageBMP

PNG_Load()  ; Load() from ImagePNG
LoadJPG()  ; Load() from ImageJPG
Load()  ; Load() from ImageBMP
This would also help converting existing code to modules. ;)