buglet (nitpick/oldman) compiling with enableexplicit
Posted: Wed May 22, 2024 2:35 am
Code: Select all
EnableExplicit
x+1
so I dutifully issue:
Code: Select all
declare x
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
EnableExplicit
x+1
Code: Select all
declare x
I think it's bad form referencing 3rd party sites for definitions, when documentation doesn't use those definitions.Demivec wrote: Wed May 22, 2024 3:23 amhttps://en.m.wikipedia.org/wiki/Declaration_(computer_programming)
Interesting. For me, if I try:Demivec wrote: Wed May 22, 2024 3:23 amIn PureBasic the terms 'declare' and 'define' are used kind of interchangeably.
Code: Select all
declare x
; or
define myProcedure()
As stated it was for reference and to save some time and make for brevity (which I'll abandon at this point). It's also bad form to poo poo my references without making any of your own to documentation. I agree to play by your groundrules and will demonstrate what I said using only PureBasisc's help manual.jassing wrote: Wed May 22, 2024 3:49 amI think it's bad form referencing 3rd party sites for definitions, when documentation doesn't use those definitions.Demivec wrote: Wed May 22, 2024 3:23 amhttps://en.m.wikipedia.org/wiki/Declaration_(computer_programming)
Reference #1: https://www.purebasic.com/documentation/reference/variables.htmlIn purebasic, you define a variable, declare a procedure
Reference #2:Variables declaration
To declare a variable in PureBasic, simply type its name. You can also specify the type you want this variable to be. By default, when a data type is not indicated, the data is an integer. Variables do not need to be explicitly declared, as they can be used as "variables on-the-fly". The Define keyword can be used to declare multiple variables in one statement. If you don't assign an initial value to the variable, their value will be 0.
Reference #3:PureBasic help entry for 'Define' wrote:Alternative possibility for the variable declaration using Define.
Reference #4:PureBasic help entry for 'Protected' wrote:Protected allows a variable to be accessed only in a Procedure even if the same variable has been declared as Global in the main program. Protected in its function is often known as 'Local' from other BASIC dialects. Each variable can have a default value directly assigned to it. If a type is specified after Protected, the default type is changed for this declaration. Protected can also be used with arrays, lists and maps.
Reference #5:PureBasic help entry for 'Static' wrote:Static allows to create a local persistent variable in a Procedure even if the same variable has been declared as Global in the main program. If a type is specified after Static, the default type is changed for this declaration. Static can also be used with arrays, lists and maps. When declaring a static array, the dimension parameter has to be a constant value.
PureBasic help entry for 'Threaded' wrote:Threaded allows to create a thread based persistent variable, arrays (except multi-dimensional arrays), lists or maps. This means every thread will have its own version of the object. This is only useful when writing multithreaded programs. If a type is specified after Threaded, the default type is changed for this declaration.
Each variable can have a default value directly assigned to it, but it has to be a constant value. Threaded initialization is done at thread first start. That implies when declaring and assigning a threaded variable in the same time, the variable is assigned for all threads. See example 2. When declaring a threaded array, the dimension parameter has to be a constant value.
A Threaded object can't be declared in a procedure, its scope is always global.
I would point out I said 'terms' not keywords.Interesting. For me, if I try:Demivec wrote: Wed May 22, 2024 3:23 amIn PureBasic the terms 'declare' and 'define' are used kind of interchangeably.I get errors. So not so interchangeable...Code: Select all
declare x ; or define myProcedure()
The error text actually reads: "With 'EnableExplicit', variables have to be declared: x."PureBasic help entry for 'Global' wrote:Global provides the ability for variables to be defined as global, i.e., variables defined as such may then be accessed within a Procedure. In this case the command Global must be called for the according variables, before the declaration of the procedure. This rule is true everywhere except in a single case: The modules do not have access to the global declared variables outside this module. Each variable may have a default value directly assigned to it. If a type is specified for a variable after Global, the default type is changed through the use of this declaration. Global may also be used with arrays, lists and maps.
It's just easier to scan. I know people don't have the time to read too many things. It also makes for an easy reference if anyone is also bugged by similar things. Everyone comes from a different background before using PureBasic for the first time. Why and why not are common questions.BarryG wrote: Wed May 22, 2024 8:20 amWow, I didn't intend for you to make such a colorful reply. Sorry man!