any kind of alfanumeric variables

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Psychophanta
Addict
Addict
Posts: 4968
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

any kind of alfanumeric variables

Post by Psychophanta »

Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: any kind of alfanumeric variables

Post by ts-soft »

-1
wikepedia wrote:In almost all languages, variable names cannot start with a digit (0-9) and cannot contain whitespace characters.
And PB is one of almost languages :wink:
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.
Image
User avatar
Psychophanta
Addict
Addict
Posts: 4968
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: any kind of alfanumeric variables

Post by Psychophanta »

ts-soft wrote:-1
wikepedia wrote:In almost all languages, variable names cannot start with a digit (0-9) and cannot contain whitespace characters.
And PB is one of almost languages :wink:
Ok,
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 :mrgreen:
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: any kind of alfanumeric variables

Post by skywalk »

That would be a nightmare for a parser. :shock:

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
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: any kind of alfanumeric variables

Post by Little John »

Psychophanta wrote:Ok,
and now...
the question is:
why not?
No, the question is: "Why?".
Variables that start with a digit are not necessary at all. On the other hand, they would cause serious problems, as skywalk showed.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: any kind of alfanumeric variables

Post by STARGÅTE »

Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
If you want to have unreadable code, use only th "_" ^^

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 moreTypeface - Sprite-based font include/module
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: any kind of alfanumeric variables

Post by freak »

Psychophanta wrote:Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
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?
Btw, your example "12e4" is already a numerical constant with the value 12000. It is called scientific notation.
quidquid Latine dictum sit altum videtur
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: any kind of alfanumeric variables

Post by ts-soft »

freak wrote:[Btw, your example "12e4" is already a numerical constant with the value 12000. It is called scientific notation.
120000.0 :wink:
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.
Image
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: any kind of alfanumeric variables

Post by xorc1zt »

STARGÅTE wrote:
Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
If you want to have unreadable code, use only th "_" ^^

Code: Select all

Procedure.s __(_, *__)
	ProcedureReturn PeekS(*__)+Str(_*_+_)
EndProcedure

_99_ = 10
_1__$ = "Hallo World! "

__.s = __(_99_, @_1__$)
Debug __
you can do even worse with lisp like using symbol as variable

example

(setf + 4)
(setf - 2)
(setf = 3)
so (* (* + -) =) will return 24 :lol:
User avatar
Psychophanta
Addict
Addict
Posts: 4968
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: any kind of alfanumeric variables

Post by Psychophanta »

mhh! Ok, in fact what freak wrote is a problem for this. :? :cry:

What about unicode characters?
So we could use greek chars, or japanese chars, or cirilic, just for variables, functions, constants,etc. names :o
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: any kind of alfanumeric variables

Post by STARGÅTE »

Psychophanta wrote:So we could use greek chars, or japanese chars, or cirilic, just for variables, functions, constants,etc. names
In the mathematica language that is even possible:

Code: Select all

φ = 3
λ = 4
Debug λ + φ ; 7
But that variable names should be translated for the ASM code.
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 moreTypeface - Sprite-based font include/module
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: any kind of alfanumeric variables

Post by Little John »

Psychophanta wrote:What about unicode characters?
So we could use greek chars, or japanese chars, or cirilic, just for variables, functions, constants,etc. names :o
-1
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.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: any kind of alfanumeric variables

Post by skywalk »

How about allowing unicode in the IDE?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: any kind of alfanumeric variables

Post by STARGÅTE »

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 moreTypeface - Sprite-based font include/module
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: any kind of alfanumeric variables

Post by skywalk »

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