Page 2 of 2
Posted: Tue Nov 11, 2003 8:31 pm
by Psychophanta
and it will break a bit the compatibility with old PB sources, but this is not big problem.
In general, when there is required a variable type as parameter for built-in functions you can make with dot as prefix.
Re:
Posted: Fri May 25, 2012 8:25 pm
by Psychophanta
Fred wrote:A good idea IHMO. It will break the compatibility with the normal 'C like' SizeOf() so I will see what can be done.
ohhh!
Still nothing done
Code: Select all
Structure localevar
a.w
b.f
c.l
EndStructure
Procedure func()
Protected localevar.b=4
Debug SizeOf(localevar) ; <- ?? 10 ?? , damn lie!, SizeOf(localevar) value is 1, not 10
EndProcedure
func()
Re: A good reason why SizeOf() refuses simple types?
Posted: Fri Jun 15, 2012 12:33 pm
by blueznl
Yeah, I'm with Psycho (that sounds sooooooo wrong). It just makes sense (and I seem to recall it's the same way ol' Gfa did it, though that's not a recommendation, I know

)
Re: Re:
Posted: Fri Jun 15, 2012 4:02 pm
by Tenaja
Psychophanta wrote:Fred wrote:A good idea IHMO. It will break the compatibility with the normal 'C like' SizeOf() so I will see what can be done.
ohhh!
Still nothing done
Code: Select all
Structure localevar
a.w
b.f
c.l
EndStructure
Procedure func()
Protected localevar.b=4
Debug SizeOf(localevar) ; <- ?? 10 ?? , damn lie!, SizeOf(localevar) value is 1, not 10
EndProcedure
func()
That struct rquires 10 bytes, so why would it return 1? A pointer would be either 4 or 8, so even if you are looking for a pointer to a struct, would still not return 1.
Re: A good reason why SizeOf() refuses simple types?
Posted: Fri Jun 15, 2012 4:14 pm
by STARGĂ…TE
he has defined (protected) a variable with the same name as structure but with the type Byte.
but the help say:
Note: if a variable and a structure have the same name, the structure will have the priority over the variable.
and I think that should stay that way.
Re: A good reason why SizeOf() refuses simple types?
Posted: Mon Sep 03, 2012 5:27 pm
by Psychophanta
Much more simple:
Gives 2 as result

Re: A good reason why SizeOf() refuses simple types?
Posted: Tue Sep 04, 2012 2:36 am
by BorisTheOld
All other BASIC languages that I've used treat data types as reserved words. Therefore, "w", "i", "q", etc, would not be allowed for the names of variables. And since structure names are used as data types, they too are treated as reserved words and are not allowed as variable names.
On the other hand, PB is like other BASICs, in that SizeOf will work with structure names but not with the built-in data types.
Although quirky, PB's rules are clear. So using built-in constants for the length of data types would be the correct thing to do.
However, although allowed, using data type names and structure names for variable names, is a bad, bad, bad!!! idea. As are single letter variable names.