Page 1 of 2
any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 10:10 pm
by Psychophanta
Is there a big problem to allow variables which start with a number?
for ex.
4t, 12e4 ...
Re: any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 10:18 pm
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

Re: any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 10:24 pm
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

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)
Re: any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 10:29 pm
by skywalk
That would be a nightmare for a parser.
Code: Select all
Define.i 1e4 = 1
Define.i 2e2 = 2
Debug 1e4 + 2e2
Re: any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 10:34 pm
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.
Re: any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 10:42 pm
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 __
Re: any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 11:02 pm
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.
Re: any kind of alfanumeric variables
Posted: Wed Feb 22, 2012 11:08 pm
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 
Re: any kind of alfanumeric variables
Posted: Thu Feb 23, 2012 12:01 am
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

Re: any kind of alfanumeric variables
Posted: Thu Feb 23, 2012 12:10 am
by Psychophanta
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

Re: any kind of alfanumeric variables
Posted: Thu Feb 23, 2012 12:57 am
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:
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.
Re: any kind of alfanumeric variables
Posted: Thu Feb 23, 2012 1:20 am
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

-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.
Re: any kind of alfanumeric variables
Posted: Thu Feb 23, 2012 1:23 am
by skywalk
How about allowing unicode in the IDE?
Re: any kind of alfanumeric variables
Posted: Thu Feb 23, 2012 1:29 am
by STARGÅTE
PB allowed to use unicode in the IDE and in the code (for strings and commands)
Re: any kind of alfanumeric variables
Posted: Thu Feb 23, 2012 2:07 am
by skywalk
Huh? Try this in integrated IDE...
Code: Select all
Define.s S$ = "ŠTĚPÁNEK ŻEWŁAKOW"
Debug s$