[DGD] typeof bug?

Par Winzell zell at skotos.net
Wed Mar 30 22:41:01 CEST 2005


Robert,

> return typeof(a) == T_STRING;
> 
> Returns 0. If I allocate an empty string to a, then it returns 1. 
> typeof(a) == T_NIL returns 1 of course, but shouldn't there be a 
> priority to refer to the type of data the variable could hold, rather 
> than what it happens to be holding at the time? Or perhaps there should 
> be another function: datatype - which returns the datatype of the 
> variable rather than its present content? Or is there a way of doing 
> that already?

This has marginal uses at best. Generally you always know what the type 
of the variable is, because you typed the piece of code that declared it 
just a couple of lines earlier. The type of a variable is a static trait 
of the compiled program.

The only use I can think of for what you suggest is a debugging macro, e.g.

# define DUMP(v)  SysLog("Value of: " + variable_name(v) + "[" + \
                          variable_datatype(v) + " is: " + \
                          lpc_to_ascii(v));

but... eh.




More information about the DGD mailing list