Page 1 of 2

Add "Static$ variable" or remove "$" for all keywords

Posted: Sun Mar 03, 2019 10:50 am
by Sicro

Code: Select all

Global$ test1
Define$ test2$

Procedure Test()
  Protected$ test3$
  Static$ test4$
EndProcedure
The keywords "Global", "Define" and "Protected" support the suffix "$", but "Static" not.

I think it should be possible, so that it is consistent.

Edit:
Or remove the suffix "$" for all keywords.
For keywords, the suffix has no advantage over ".s", as it is the case on variables.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 1:30 pm
by STARGÅTE
What is the meaning of $ after Global, Define, ...
I can't find a documentation entry for this.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 2:12 pm
by Josh
STARGÅTE wrote:What is the meaning of $ after Global, Define, ...
I think these are some relics from Pb starting time. This is also available with Procedure$.

There are several stupid things (sorry Fred) like '=<' or '=>' that don't make a code any better and should be removed.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 2:14 pm
by Sicro
"$" = ".s"

The suffix "$" works also on many other keywords -- Read$/Data$ (DataSection), Procedure$, etc. --, not only on variables.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 2:51 pm
by Dude
Josh wrote:There are several stupid things (sorry Fred) like '=<' or '=>' that don't make a code any better and should be removed.
How would you propose to do "less than or equal to" then?

PureBasic is Basic, and "=<" is standard Basic.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 3:19 pm
by Josh
Dude wrote:
Josh wrote:There are several stupid things (sorry Fred) like '=<' or '=>' that don't make a code any better and should be removed.
How would you propose to do "less than or equal to" then?

PureBasic is Basic, and "=<" is standard Basic.
As you wrote, it means "less than or equal." It is not called "equal or less than". In Basic dialects like VB6, VBA, QBasic '<=' is used. Even if it works the other way around, it doesn't make sense and doesn't make a code any better.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 3:50 pm
by Dude
Surely you jest? :shock:

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 4:21 pm
by Little John
Sicro wrote:"$" = ".s"
Sorry, this is not exactly correct.

The suffix ".s" is only needed for the declaration. Otherwise, it can be appended to a variable name, but there is no need to do so.
In contrast, the suffix "$" is part of the variable name. If a string is declared with suffix "$", then that suffix has to be appended always to the variable name:

Code: Select all

; PB 5.70 LTS

Define foo.s
Define bar$

foo.s = "Hello"   ; allowed
foo   = "Hello"   ; allowed
bar$  = "world"   ; allowed
; bar = "world"   ; not allowed, because 'bar' is an integer variable
Sicro wrote:The keywords "Global", "Define" and "Protected" support the suffix "$", but "Static" not.
My suggestion for removing that inconsistency is, not to allow "Global$", "Define$", "Protected$" and "Procedure$" anymore, because that doesn't make sense IMHO.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 4:24 pm
by TI-994A
Dude wrote:PureBasic is Basic, and "=<" is standard Basic.
Relational operators in almost all conventions tend to place the non-equal comparative before the equal one (ie: <= >= !=).

However, PureBasic is hardly a conventional programming language. While the flipped syntax is convenient, better to stick to mainstream conventions; in case it's enforced in future versions.

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 4:48 pm
by TI-994A
Little John wrote:...not to allow "Global$", "Define$", "Protected$" and "Procedure$" anymore, because that doesn't make sense...
The string symbol ($) goes back to the early days of BASIC, where most string functions were suffixed with it (eg: STR$, LTRIM$, UCASE$, MKI$, etc.).

Nice to maintain some pure BASIC legacy. :wink:

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 5:07 pm
by Little John
TI-994A wrote:
Little John wrote:...not to allow "Global$", "Define$", "Protected$" and "Procedure$" anymore, because that doesn't make sense...
The string symbol ($) goes back to the early days of BASIC, where most string functions were suffixed with it (eg: STR$, LTRIM$, UCASE$, MKI$, etc.).
Yes. And as you know, PureBasic does not follow that tradition, since those functions are named STR, LTRIM, UCASE etc. in PureBasic. ;-)

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 5:18 pm
by Sicro
Little John wrote:
Sicro wrote:"$" = ".s"
Sorry, this is not exactly correct.
In the case of using it as a suffix on the keywords, it is correct and this was the question.
But thank you for clarifying the different meaning of the suffix for variables.
Little John wrote:In contrast, the suffix "$" is part of the variable name. If a string is declared with suffix "$", then that suffix has to be appended always to the variable name:
Yes, that's why I like "$" more than ".s" on string variables. So it is always clear which variables are for numbers and which are for strings, without having to think up a prefix/suffix yourself.
Little John wrote:My suggestion for removing that inconsistency is, not to allow "Global$", "Define$", "Protected$" and "Procedure$" anymore, because that doesn't make sense IMHO.
I think the suffix on "Procedure", "Data" and "Read" is ok, but can also be removed, because it has no advantage over ".s".
For the other keywords, I don't use the suffix:

Code: Select all

Global$ variable$
Nonsense in my case, because I always use the suffix on string variables.
That's enough:

Code: Select all

Global variable$

Re: Add support for "Static$ variable"

Posted: Sun Mar 03, 2019 5:38 pm
by Little John
Sicro wrote:
Little John wrote:
Sicro wrote:"$" = ".s"
Sorry, this is not exactly correct.
In the case of using it as a suffix on the keywords, it is correct and this was the question
Ooops. I mixed that up, sorry! You are right, of course.

Well ... using them as suffix for those keywords, "$" and ".s" have the same effect.
But using them as suffix for variable names, "$" and ".s" do not have the same effect. :cry: Another inconsistency ... One more reason IMHO for removing support for Define$, Global$ etc. from the language.

Re: Add "Static$ variable" or remove "$" for all keywords

Posted: Sun Mar 03, 2019 6:06 pm
by Josh
Global$ etc. occupies useless variable names. Even if these identifiers can be used in the code, it simply looks unattractive and confusing at a quick look at the code.
Structure MyStruc
  aaa.i
  bbb.i
  Global$
  ccc.i
EndStructure

Re: Add "Static$ variable" or remove "$" for all keywords

Posted: Mon Mar 04, 2019 9:39 am
by #NULL
Josh wrote:Global$ etc. occupies useless variable names. Even if these identifiers can be used in the code, it simply looks unattractive and confusing at a quick look at the code.
Structure MyStruc
  aaa.i
  bbb.i
  Global$
  ccc.i
EndStructure
or..

Code: Select all

Global$ Global$ = "abc"
I think in the EU it should be

Code: Select all

Global€ Global€ = "abc"
:mrgreen: