any kind of alfanumeric variables
- Psychophanta
- Addict
- Posts: 4968
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
any kind of alfanumeric variables
Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
for ex.
4t, 12e4 ...
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
Re: any kind of alfanumeric variables
-1
And PB is one of almost languageswikepedia wrote:In almost all languages, variable names cannot start with a digit (0-9) and cannot contain whitespace characters.
PureBasic 5.73 | 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.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
- Psychophanta
- Addict
- Posts: 4968
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: any kind of alfanumeric variables
Ok,ts-soft wrote:-1
And PB is one of almost languageswikepedia wrote:In almost all languages, variable names cannot start with a digit (0-9) and cannot contain whitespace characters.
and now...
the question is:
why not?
(NOTICE: answers like "because every language is not like that" or "because everytime has been like that", etc, are not considered valid, because it is not a valid argue)
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
Re: any kind of alfanumeric variables
That would be a nightmare for a parser.
Code: Select all
Define.i 1e4 = 1
Define.i 2e2 = 2
Debug 1e4 + 2e2
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: any kind of alfanumeric variables
No, the question is: "Why?".Psychophanta wrote:Ok,
and now...
the question is:
why not?
Variables that start with a digit are not necessary at all. On the other hand, they would cause serious problems, as skywalk showed.
Re: any kind of alfanumeric variables
If you want to have unreadable code, use only th "_" ^^Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
Code: Select all
Procedure.s __(_, *__)
ProcedureReturn PeekS(*__)+Str(_*_+_)
EndProcedure
_99_ = 10
_1__$ = "Hallo World! "
__.s = __(_99_, @_1__$)
Debug __
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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: any kind of alfanumeric variables
Yes, because that would make "42" a valid variable name. So what if you actually want to use the number 42 somewhere? How do you calculate the answer to life, the universe and everything?Psychophanta wrote:Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
Btw, your example "12e4" is already a numerical constant with the value 12000. It is called scientific notation.
quidquid Latine dictum sit altum videtur
Re: any kind of alfanumeric variables
120000.0freak wrote:[Btw, your example "12e4" is already a numerical constant with the value 12000. It is called scientific notation.
PureBasic 5.73 | 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.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Re: any kind of alfanumeric variables
you can do even worse with lisp like using symbol as variableSTARGÅTE wrote:If you want to have unreadable code, use only th "_" ^^Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...Code: Select all
Procedure.s __(_, *__) ProcedureReturn PeekS(*__)+Str(_*_+_) EndProcedure _99_ = 10 _1__$ = "Hallo World! " __.s = __(_99_, @_1__$) Debug __
example
(setf + 4)
(setf - 2)
(setf = 3)
so (* (* + -) =) will return 24
- Psychophanta
- Addict
- Posts: 4968
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: any kind of alfanumeric variables
mhh! Ok, in fact what freak wrote is a problem for this.
What about unicode characters?
So we could use greek chars, or japanese chars, or cirilic, just for variables, functions, constants,etc. names
What about unicode characters?
So we could use greek chars, or japanese chars, or cirilic, just for variables, functions, constants,etc. names
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
Re: any kind of alfanumeric variables
In the mathematica language that is even possible:Psychophanta wrote:So we could use greek chars, or japanese chars, or cirilic, just for variables, functions, constants,etc. names
Code: Select all
φ = 3
λ = 4
Debug λ + φ ; 7
But you can write a precompiler, which convert the unicode characters (in variables and functions) to alpha numeric names.
λamba -> U03BBamba or so.
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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: any kind of alfanumeric variables
-1Psychophanta wrote:What about unicode characters?
So we could use greek chars, or japanese chars, or cirilic, just for variables, functions, constants,etc. names
I really hope that this is not going to happen.
When greek people would use greek characters for identifiers, this would not be understandable for the rest of the people in the world; when japanese people would use japanese characters for identifiers, this would not be understandable for the rest of the people in the world; etc.
The main purpose of any (natural or technical) language is to allow for versatile, reliable and as easy as possible communication among all individuals for whom this is of benefit. Thanks to the internet, we live in a "global village" today, and also everyone here on the forum benefits from this fact. In our "global village" it's already a considerable problem that there are so many different natural languages. We can be happy when a technical language such as PureBasic does not repeat the problem of the diversity of the natural languages, but makes it as easy as posible for all PureBasic programmers in the world to read and understand each other's code.
Re: any kind of alfanumeric variables
How about allowing unicode in the IDE?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: any kind of alfanumeric variables
PB allowed to use unicode in the IDE and in the code (for strings and commands)
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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: any kind of alfanumeric variables
Huh? Try this in integrated IDE...
Code: Select all
Define.s S$ = "ŠTĚPÁNEK ŻEWŁAKOW"
Debug s$
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum