Page 1 of 1

Modules break EnableExplicit

Posted: Tue Oct 18, 2016 9:42 am
by MrTAToad
The following code breaks EnableExplicit, because it prints the value of a non-defined variable, when SpiderBasic should produce a compiler error

Code: Select all

EnableExplicit

DeclareModule Test
  Declare.b moo()
EndDeclareModule

Module Test
  Procedure.b moo()
    Debug "The value of a : "+Str(a)
  EndProcedure
EndModule

Test::moo()

Re: Modules break EnableExplicit

Posted: Tue Oct 18, 2016 10:02 am
by ts-soft
Where is the EnableExplicit for the Module?

Code: Select all

EnableExplicit

DeclareModule Test
  EnableExplicit
  
  Declare.b moo()
EndDeclareModule

Module Test
  Procedure.b moo()
    Debug "The value of a : "+Str(a)
  EndProcedure
EndModule

Test::moo()
No bug!

Re: Modules break EnableExplicit

Posted: Tue Oct 18, 2016 11:09 am
by MrTAToad
It looks like the EnableExplicit documentation needs updating as I thought it was a totally global command

Re: Modules break EnableExplicit

Posted: Tue Oct 18, 2016 1:36 pm
by ts-soft
I have no spiderbasic, but from the purebasic help:
purebasic.chm wrote:When the statements Define, EnableExplicit, EnableASM are used inside a module, they have no effect outside the respective module, and vice versa.

Re: Modules break EnableExplicit

Posted: Tue Oct 18, 2016 1:38 pm
by SparrowhawkMMU
MrTAToad wrote:It looks like the EnableExplicit documentation needs updating as I thought it was a totally global command
I thought the same - took me while to realise it's not truly global. Caused me a little bit of grief that one :)

Re: Modules break EnableExplicit

Posted: Wed Oct 19, 2016 9:45 am
by MrTAToad
Yes - caused a few problems here too :)

Re: Modules break EnableExplicit

Posted: Wed Oct 19, 2016 10:31 am
by ts-soft
Without this feature, the Namespace of modules is not to be used really sensibly.

Re: Modules break EnableExplicit

Posted: Wed Oct 19, 2016 12:27 pm
by MrTAToad
Quite true

Re: Modules break EnableExplicit

Posted: Wed Oct 19, 2016 12:53 pm
by Fred
The idea behind the modules is you can share it and include it in your project asap. If someone wants to write a module without EnableExplicit, he can, and if you include it with EnableExplicit in your code, it will still work.