Modules break EnableExplicit

Just starting out? Need help? Post your questions and find answers here.
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Modules break EnableExplicit

Post 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()
User avatar
ts-soft
Posts: 9
Joined: Wed Feb 26, 2014 2:00 pm
Location: Berlin - Germany

Re: Modules break EnableExplicit

Post 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!
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: Modules break EnableExplicit

Post by MrTAToad »

It looks like the EnableExplicit documentation needs updating as I thought it was a totally global command
User avatar
ts-soft
Posts: 9
Joined: Wed Feb 26, 2014 2:00 pm
Location: Berlin - Germany

Re: Modules break EnableExplicit

Post 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.
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
SparrowhawkMMU
Posts: 291
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Modules break EnableExplicit

Post 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 :)
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: Modules break EnableExplicit

Post by MrTAToad »

Yes - caused a few problems here too :)
User avatar
ts-soft
Posts: 9
Joined: Wed Feb 26, 2014 2:00 pm
Location: Berlin - Germany

Re: Modules break EnableExplicit

Post by ts-soft »

Without this feature, the Namespace of modules is not to be used really sensibly.
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: Modules break EnableExplicit

Post by MrTAToad »

Quite true
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Modules break EnableExplicit

Post 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.
Post Reply