Page 2 of 2

Re: Modules and name clashing.

Posted: Sun Jun 23, 2013 12:57 am
by luis
freak wrote: Imho, these are the two styles that are useful with Modules
- give descriptive names that stand on their own, use UseModule and only write the full name to avoid (rare) conflicts
- give shorter names for simplicity inside the module and write the full name outside to keep the meaning of the call clear

I agree those are the two sensible options.

I find the second option not particularly appealing because of the need to qualify every constant passed to the module:

Code: Select all

DeclareModule test
 #const1 = 10
 Declare proc(par)
EndDeclareModule

Module test
 Procedure proc(par)
  Debug "proc" + par
 EndProcedure
EndModule

test::proc(test::#const1)
I would really dislike the need of doing this for every constant associated to the library, at this point I can just use the old prefix method (three letters plus underscore in front of procs, macros, constants, etc.).

The discussion here was intended by me as worst case scenarios, when you already did what was sensible to do but wasn't enough to avoid conflicts.
I like to analyze the worst cases even when they can be avoided most of the time, to know what my options are when common good practices are not enough.
I'll have to experiment a little with a real lib to see what's the option I feel more comfortable with, if any.

Thanks for the suggestions

Re: Modules and name clashing.

Posted: Tue Jun 25, 2013 6:33 pm
by uwekel
freak wrote:There is also a HideModule command which closes the module again.
I think EndUseModule would better fit into PB syntax.

Re: Modules and name clashing.

Posted: Wed Jun 26, 2013 4:14 pm
by User_Russian
uwekel wrote:I think EndUseModule would better fit into PB syntax.
No, if you follow the PB syntax, it should be CloseModule.

Re: Modules and name clashing.

Posted: Wed Jun 26, 2013 4:17 pm
by luis
User_Russian wrote:
uwekel wrote:I think EndUseModule would better fit into PB syntax.
No, if you follow the PB syntax, it should be CloseModule.
In this very same thread
freak wrote: This is why the keyword is called "UseModule" and not "OpenModule": Opening something implies that it needs to be closed after use. But that is not the common use case here. You can just "use" the module and never "unuse" it.
And anyway has just been changed in B3 to "UnuseModule" (bleah :) )

Re: Modules and name clashing.

Posted: Wed Jun 26, 2013 8:46 pm
by uwekel
luis wrote:And anyway has just been changed in B3 to "UnuseModule" (bleah :) )
Outch! :?