any kind of alfanumeric variables

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: any kind of alfanumeric variables

Post by STARGÅTE »

File -> File-format -> UFT8
compiler -> enable unicode
Debug -> MessageRequester

and i get:

Code: Select all

Define String.s = "ŠTĚPÁNEK ŻEWŁAKOW"

MessageRequester("", String)
---------------------------

---------------------------
ŠTĚPÁNEK ŻEWŁAKOW
---------------------------
OK
---------------------------
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: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: any kind of alfanumeric variables

Post by skywalk »

umm, debug output?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: any kind of alfanumeric variables

Post by Psychophanta »

I get
ŠTĚPÁNEK ŻEWŁAKOW

with:
File -> File-format -> plain text
compiler -> DIsable unicode

with debug output and also with MessageRequester
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: any kind of alfanumeric variables

Post by Tenaja »

Psychophanta wrote: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)
The biggest reason "nobody does it that way" is because when we are about 12 years old, we learn that y=4x means y=4*x. To permit a number in the first position of a variable will confuse 100% of the new users. It is not merely a "different way to do things," but it contradicts everything taught about variables and numbers outside of programming--and these practices are centuries old. That's why nobody does it that way; to avoid confusion.

As far as parsing goes, it is trivial to implement it, and has nothing to do with the decision. PB has a super simple parser, so perhaps it only looks at the first character to determine the next token for all numbers (123, $123, #abc, etc.), but many languages allow mixing of numbers and characters (0x123, 0b1001, for instance), and allowing this would be far from complex. The syntax is simple, very easy to implement, and would not require "42" to be a variable if you require that all variable-names contain at least one non-number character. In fact, it would be no more difficult than allowing the underscore in a name.

So, why not? Mostly, to avoid confusion.
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: any kind of alfanumeric variables

Post by charvista »

Clarity would be lost and confusion would be huge, but you can use the underscore symbol :mrgreen:

Code: Select all

_12e4=4
_4t=-7
_42=-2
Debug _12e4*(_4t-_42)+(_12e4+_42)*_4t
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: any kind of alfanumeric variables

Post by Psychophanta »

charvista wrote:Clarity would be lost and confusion would be huge, but you can use the underscore symbol :mrgreen:

Code: Select all

_12e4=4
_4t=-7
_42=-2
Debug _12e4*(_4t-_42)+(_12e4+_42)*_4t
Good and simple idea, just useful for me. Thanks!
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply