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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

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

Post 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.
Last edited by Sicro on Sun Mar 03, 2019 5:34 pm, edited 3 times in total.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
User avatar
STARGÅTE
Addict
Addict
Posts: 2088
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Add support for "Static$ variable"

Post by STARGÅTE »

What is the meaning of $ after Global, Define, ...
I can't find a documentation entry for this.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Add support for "Static$ variable"

Post 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.
Last edited by Josh on Sun Mar 03, 2019 2:15 pm, edited 1 time in total.
sorry for my bad english
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Add support for "Static$ variable"

Post by Sicro »

"$" = ".s"

The suffix "$" works also on many other keywords -- Read$/Data$ (DataSection), Procedure$, etc. --, not only on variables.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Add support for "Static$ variable"

Post 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.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Add support for "Static$ variable"

Post 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.
sorry for my bad english
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Add support for "Static$ variable"

Post by Dude »

Surely you jest? :shock:
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Add support for "Static$ variable"

Post 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.
Last edited by Little John on Sun Mar 03, 2019 4:24 pm, edited 1 time in total.
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Add support for "Static$ variable"

Post 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.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Add support for "Static$ variable"

Post 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:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Add support for "Static$ variable"

Post 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. ;-)
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Add support for "Static$ variable"

Post 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$
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Add support for "Static$ variable"

Post 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.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

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

Post 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
sorry for my bad english
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

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

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