Global EnableExplicit

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Global EnableExplicit

Post by uwekel »

Hi,

i would like to have a setting for EnableExplicit in the compiler options and default compiler settings dialogs. Once selected, there would be no need to put the compiler directive at the top of each source code.

Best regards
Uwe
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Global EnableExplicit

Post by PB »

But then when you post some code here, those without that
directive won't be able to compile your code unless they type
it manually -- every time. It'll cause inconvenience to others.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Global EnableExplicit

Post by Danilo »

PB wrote:But then when you post some code here, those without that
directive won't be able to compile your code unless they type
it manually -- every time. It'll cause inconvenience to others.
Nope. EnableExplicit means you have to declare all variables before use.
When removing EnableExplicit, the code still runs, as everything is properly declared already.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Global EnableExplicit

Post by PB »

You're right. I wasn't thinking clearly due to my spam fight
still being on my mind. Time to have a beer and relax, I think.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Global EnableExplicit

Post by mestnyi »

uwekel wrote:Hi,

i would like to have a setting for EnableExplicit in the compiler options and default compiler settings dialogs. Once selected, there would be no need to put the compiler directive at the top of each source code.

Best regards
Uwe
I would put +1 but do not know how. :oops:
User avatar
Derren
Enthusiast
Enthusiast
Posts: 316
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Global EnableExplicit

Post by Derren »

+1 as well

There was a discussion about why there's a compiler directive instead of just natively using it. But I can't remember the reasons against it.
User avatar
langinagel
Enthusiast
Enthusiast
Posts: 131
Joined: Fri Jan 28, 2005 11:53 pm
Location: Germany
Contact:

Re: Global EnableExplicit

Post by langinagel »

Indifferent.
It is feasible but more effort for postings.
In case of bug test or other short *concept* scripts you have to fiddle on the compiler options.

It seems that you guys assume everyone is so professional on the style guide that every posting here would comply to Enableexplicit.
Congrats to you, keep on! But then the short line Enableexplicit should not bother you.

But there are enough amateurs like e,g, me that might post code that does not declare all variables. I would prefer to have your response as well.
https://www.doerpsoft.org

Boost. Work. Efficiency.
User avatar
Derren
Enthusiast
Enthusiast
Posts: 316
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Global EnableExplicit

Post by Derren »

Considering how many "help" posts could be solved with EnableExplicit, showing typos in variable names and so on, there's no reason not to use it, even for a 20 line code.

BUT, I'd like "local" counter variables as well. Explicit declaration has its merits, but not for "For" loops. Since the variable is reset anyway, it doesn't matter if it was declared before or not.

Code: Select all

Define i=20 
For i=5 To 15
  Debug i
Next
Debug i ;should be 20, not 15 (uhm, it's 16, but no idea why oO) or throw a "not defined" error if the first line wouldn't exist
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Global EnableExplicit

Post by DK_PETER »

Guys...really??? :shock:
Is this really such a big deal?
A tiny one line command needs to be added to your code...
Use it or don't...Don't make a big deal out of absolutely nothing.
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Post Reply