PDA

View Full Version : all those keywords...



ReneMiner
27-01-2015, 11:21
something that annoys probably not me only, is the situation if creating some new udt and finding names for the udt-elements - and 99% of those i would like to use are occupied by some thinBasic-keyword already :tears:

Can't we write those udt-element-names optional in quotes to avoid this?

They always have a dot in front in all other cases - so not very likely to get interpreted as keyword then (except from thinAir)



Type t_example
"Name" As String
"User" As Long
End Type

dim my as t_example
my.Name = "René"
With my
.User = 123
End With


PS- there's some new keyword "Version" - because of that - and something else - Petr's TBASS-3d-Sound-unit does not work any more
and there's some other reason - somethings wrong with TBASS i fear- i don't get sound :(

Petr Schreiber
29-01-2015, 02:37
Hi Rene,

in my opinion, this is very important issue. I think we need to be able to name the UDT elements with any name, even when same as already defined keywords.
Not with quotes, but simply by default, out of the box, as it is in other languages.

ThinBASIC parser has the ability to know it is inside TYPE / END TYPE scope, so it should be possible.

Otherwise, we easily fall in completlely anti-future proof problems, like the one Rene describes.

The same should apply for parameter names of functions!


Petr

Michael Clease
29-01-2015, 10:50
I find prefix the datatype in front of the variable name stops keyword clash but also gives me reminders of the datatype being used.



Type t_example
sName As String
lUser As Long
End Type


dim my as t_example
my.sName = "René"
With my
.lUser = 123
EndWith

ReneMiner
29-01-2015, 16:03
for variables that makes sense, but what if it's a type-function?
All prefix them using "f" + the returned vartype? How will the code read then....

Michael Clease
29-01-2015, 16:42
Type tMytype
sfred as string
dwLunch as function
end type

Function dwLunch(byref lRoach as long) as DWORD

DIM lizardpeople as tMytype

ReneMiner
29-01-2015, 18:01
...
Function dwLunch(byref roach as long) as DWORD
...


wouldn't that be "lRoach" then ? :D