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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

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

Post by Marc56us »

After using for years .s, I now prefer to use $ for text variables.
So, if I pick up a code later, there is no need to go back to the variable declaration to know if it is a numeric or text variable and fewer possible errors.
The creators of the basic had good ideas from the beginning.

:wink:
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

Marc56us wrote:After using for years .s, I now prefer to use $ for text variables.
So, if I pick up a code later, there is no need to go back to the variable declaration to know if it is a numeric or text variable and fewer possible errors.
That's why I also prefer $ for string variables.

However, this thread is about .s and $ as suffixes for some keywords, not for variables. I had mixed that up, too. :-)

@Sicro:
Thank you for editing the title and the first post!
olafmagne
New User
New User
Posts: 4
Joined: Tue Jun 04, 2019 11:22 am

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

Post by olafmagne »

Hello,

I totally agree,that the $-sign is useless for declaration-keywords,
but,on the other hand, as a trailing-sign for functions/procedures,also for userwritten , it make sence.
every now and then,i find myself writing it and then wondering,what syntax-error i have made.
IMHO,get rid of it on declarations and add it to the functions as whe know from times gone by (C64 on my mind)

Olaf
User avatar
skywalk
Addict
Addict
Posts: 3997
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

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

Post by skywalk »

This is what makes PureBasic so helpful when browsing code.
I know immediately I am staring at a string variable x$ or a pointer *ptr.
C drops the pointer(*) after defining and that is a big reason for so many memory bugs.
PureBasic syntax also allows you to retain the .type tail, but I find that too much noise.
For i.i = 0 to nPts.i
x.d + i.i
Next i.i
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 666
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

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

Post by Kurzer »

Marc56us wrote:After using for years .s, I now prefer to use $ for text variables.
So, if I pick up a code later, there is no need to go back to the variable declaration to know if it is a numeric or text variable and fewer possible errors.
The creators of the basic had good ideas from the beginning.

:wink:
i dropped using the $ in variables, because i am using a mix of hungary notation and camelcase notation for my variables to determine the variable type on the first sight.

eg.
iNumOfCars ; integer
sNameOfDriver ; string
fSpeedOfCar ; float
dAmountOfGas ; double
stCars ; structured type
and so on...

Sent via mobile phone
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
olafmagne
New User
New User
Posts: 4
Joined: Tue Jun 04, 2019 11:22 am

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

Post by olafmagne »

skywalk wrote:This is what makes PureBasic so helpful when browsing code.
I know immediately I am staring at a string variable x$ or a pointer *ptr.
C drops the pointer(*) after defining and that is a big reason for so many memory bugs.
PureBasic syntax also allows you to retain the .type tail, but I find that too much noise.
For i.i = 0 to nPts.i
x.d + i.i
Next i.i
I totally agree

Olaf
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: Add

Post by Tenaja »

kurzer wrote: eg.
iNumOfCars ; integer
sNameOfDriver ; string
fSpeedOfCar ; float
dAmountOfGas ; double
stCars ; structured type
and so on...

Sent via mobile phone
That's what I do... Been doing it since I read that how to program windows book in the early x0's...
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

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

Post by Sicro »

kurzer wrote:eg.
iNumOfCars ; integer
sNameOfDriver ; string
fSpeedOfCar ; float
dAmountOfGas ; double
stCars ; structured type
and so on...
Appending the variable type as prefix to the variable name has the disadvantage that the variable type must first be written for the auto-completion function. Usually, however, you only remember the approximate variable name and not also the variable type of the variable.

As long as PureBasic does not use a fuzzy search for auto-completion, the variable type is better appended to the variable name as a suffix in my opinion.
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
Post Reply