Case Sensitives Variables etc..
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
Dear PB users,
I'm thinking to change the way how PB handle Variables, Procedures, Constants Structures, LinkedList and Array names. For now, all is case sensitive which means than 'myVariable' is different than 'MYVARIABLE'. I think it could produce more error code and stupid mistakes. All will be case insensitive. What do you think ?
Fred - AlphaSND
Dear PB users,
I'm thinking to change the way how PB handle Variables, Procedures, Constants Structures, LinkedList and Array names. For now, all is case sensitive which means than 'myVariable' is different than 'MYVARIABLE'. I think it could produce more error code and stupid mistakes. All will be case insensitive. What do you think ?
Fred - AlphaSND
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Don.
Hi Fred
I think this would be a good idea. I use mixed case variables etc. and a few times I have accidentally changed the case of 1 letter which means that PB thinks I'm using a new variable - which defaults to zero and causes nasty problems. This has happened to me a few times, so I'm in favour of making them case insensitive. Also, I think this might make PB more consistent with other Basics.
Don
Hi Fred
I think this would be a good idea. I use mixed case variables etc. and a few times I have accidentally changed the case of 1 letter which means that PB thinks I'm using a new variable - which defaults to zero and causes nasty problems. This has happened to me a few times, so I'm in favour of making them case insensitive. Also, I think this might make PB more consistent with other Basics.
Don
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
because it's faster to type that way. (I only post here in mixed case for the
benefit of others who may find all lowercase harder to read).
PB - Registered PureBasic Coder
Edited by - PB on 16 January 2002 23:12:14
Yep, do it. I code in all lowercase anyway ("messagerequester", variables, etc)All will be case insensitive. What do you think ?
because it's faster to type that way. (I only post here in mixed case for the
benefit of others who may find all lowercase harder to read).
PB - Registered PureBasic Coder
Edited by - PB on 16 January 2002 23:12:14
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Fangbeast.
Fangles
I agree too. I make too many stupid muistakes due to typing and then spending hours fixing it up. I don't usually type all lowercase because I like to emphasize the code or function that I am working on but that leads to typing errors. Thanks Fred!
Dear PB users,
I'm thinking to change the way how PB handle Variables, Procedures, Constants Structures, LinkedList and Array names. For now, all is case sensitive which means than 'myVariable' is different than 'MYVARIABLE'. I think it could produce more error code and stupid mistakes. All will be case insensitive. What do you think ?
Fred - AlphaSND
Fangles
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Hi Fred.
This sounds good, as it only makes sense to have case sensitive variables if you have to predefine all your variables i.e. the compiler tells you if a variable is not defined. Now you can get all sorts of trouble if one letter in a variable differ in lower or upper case.
That procedures,structures,linkedlists and arrays are case sensitive is not a problem because the compiler tells if you've made a mistake in those cases.
What would be great, i think, is if you could have the option to predefine all variables you use and the compiler tells if you're trying to use an undefined variable. This would prevent stupid typing mistakes like 'variable.l' becoming 'varible.l'. Such typing mistakes can easily lead to errors that is hard to find. This method would be optional and you should be able to choose not to use it. Perhaps it could be controlled/(turned on) by a keyword at the top of your code like this:
Anyway just som ideas. For starters, making variables case insensitive will help alot.
Hi Fred.
This sounds good, as it only makes sense to have case sensitive variables if you have to predefine all your variables i.e. the compiler tells you if a variable is not defined. Now you can get all sorts of trouble if one letter in a variable differ in lower or upper case.
That procedures,structures,linkedlists and arrays are case sensitive is not a problem because the compiler tells if you've made a mistake in those cases.
What would be great, i think, is if you could have the option to predefine all variables you use and the compiler tells if you're trying to use an undefined variable. This would prevent stupid typing mistakes like 'variable.l' becoming 'varible.l'. Such typing mistakes can easily lead to errors that is hard to find. This method would be optional and you should be able to choose not to use it. Perhaps it could be controlled/(turned on) by a keyword at the top of your code like this:
Code: Select all
PreDefine ; Keyword we want to check our variables
Structure Test
x.w
y.w
EndStructure
DefineVar ; starts the defining zone
a.l
b.w
c.Test
...
EndDefineVar ; end defining zone
...
Procedure TestProc(arg1.l,arg2.l)
DefineVar ; New define zone, only for local variables
x.w,y.w,z.l
EndDefineVar
...
EndProcedure
...
End
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
It's ok, I will change all that. About the Predefine Keyword, why not it's a good idea. I'm thinking to use only one keyword (Predefine) and all variables followed by a type (.f, .l etc..) will be considered as declared. All variables with no type and undeclared will lead a compiler error. Right ?
Fred - AlphaSND
It's ok, I will change all that. About the Predefine Keyword, why not it's a good idea. I'm thinking to use only one keyword (Predefine) and all variables followed by a type (.f, .l etc..) will be considered as declared. All variables with no type and undeclared will lead a compiler error. Right ?
Fred - AlphaSND
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Fred, if you can do it without spending half of your life, can you install a compiler switch under the menu compiler options for doing that?
So if a code is not working, but it should, anybody can switch to case insensitive.
And if the code is running well the coder knows what happend.
What do you think?
Have a nice day...
Franco
That's right, but ... ups I like case sensitive. I like a high quality of written code. (I'm the only one? My name is NOT Tigger!)For starters, making variables case insensitive will help alot.
Fred, if you can do it without spending half of your life, can you install a compiler switch under the menu compiler options for doing that?
So if a code is not working, but it should, anybody can switch to case insensitive.
And if the code is running well the coder knows what happend.
What do you think?
Have a nice day...
Franco
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
I'll show two examples:
Right! Just to make everything clear, you have to predefine the variables in the procedures separately, so if for example 'variable.l' is defined at the top of the program(and isn't Global) you shouldn't be able to use it in a procedure.It's ok, I will change all that. About the Predefine Keyword, why not it's a good idea. I'm thinking to use only one keyword (Predefine) and all variables followed by a type (.f, .l etc..) will be considered as declared. All variables with no type and undeclared will lead a compiler error. Right ?
I'll show two examples:
Code: Select all
;this is legal
PreDefine variable.l
Procedure test(arg.l)
PreDefine variable.l
variable=variable+arg ; i.e. arg.l is in a sense predefined in this procedure
...
EndProcedure
;this is not legal
Predefine variable.l
Procedure test(arg.l)
variable=variable+arg ; 'variable' is not locally predefined and isn't global
;or shared!
...
endprocedure
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
Hello Franco,
I like Variable sensitive too, but even with variable insensitive you could write good formatted (high quality) code. It just make the code much more error proof in case of you do a spelling mistake. In don't want to make a switch because it would say than a program which work in case sensitive mode (imagine you use myVariable and MYVARIABLE like 2 differents one) willn't work in case insensitive mode. PureBasic will follow this BASIC concept and AFAIK it's the default behavior for other BASIC language. I've started this topic by seeing your post about the constant #PB_KEY_SPACE
. BTW, I've done some mistake myself about bad var naming so it should solve this in a clean way.
Fred - AlphaSND
Hello Franco,
I like Variable sensitive too, but even with variable insensitive you could write good formatted (high quality) code. It just make the code much more error proof in case of you do a spelling mistake. In don't want to make a switch because it would say than a program which work in case sensitive mode (imagine you use myVariable and MYVARIABLE like 2 differents one) willn't work in case insensitive mode. PureBasic will follow this BASIC concept and AFAIK it's the default behavior for other BASIC language. I've started this topic by seeing your post about the constant #PB_KEY_SPACE

Fred - AlphaSND
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Rings.
yes do it fred.
most of my beginner-mistakes are case sensitive Problems.
Siggi
like Option Explicite in VB ?My idea was to only put one directive (PreDefine) at the top of the source code and that's all. So all variables must be typed at their first use. Not good ?
yes do it fred.
most of my beginner-mistakes are case sensitive Problems.
Siggi
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Well, your idea is probably the easisest to implement with minimum of changes to the compiler code. So go for it!Hello Pupil,
My idea was to only put one directive (PreDefine) at the top of the source code and that's all. So all variables must be typed at their first use. Not good ?
Fred - AlphaSND
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm