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.
Add "Static$ variable" or remove "$" for all keywords
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Add "Static$ variable" or remove "$" for all keywords
That's why I also prefer $ for string variables.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.
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!
Re: Add "Static$ variable" or remove "$" for all keywords
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
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
Re: Add "Static$ variable" or remove "$" for all keywords
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 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
Re: Add "Static$ variable" or remove "$" for all keywords
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.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.
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!"
"Happiness is a pet." | "Never run a changing system!"
Re: Add "Static$ variable" or remove "$" for all keywords
I totally agreeskywalk 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
Olaf
Re: Add
That's what I do... Been doing it since I read that how to program windows book in the early x0's...kurzer wrote: eg.
iNumOfCars ; integer
sNameOfDriver ; string
fSpeedOfCar ; float
dAmountOfGas ; double
stCars ; structured type
and so on...
Sent via mobile phone
Re: Add "Static$ variable" or remove "$" for all keywords
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.kurzer wrote:eg.
iNumOfCars ; integer
sNameOfDriver ; string
fSpeedOfCar ; float
dAmountOfGas ; double
stCars ; structured type
and so on...
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.
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