Hello.
There is an interest connected with the tagging system of PAWN.
There is a
tagof operator, but I cannot understand how does it work.
Quote:
tagof s
results in the a unique number that represents the tag of the variable,
the constant, the function result or the tag label.
When used in a default value for a function argument, the expression
is evaluation at the point of the function call, instead of in the
function denition.
|
The context is the following: when we use a function like this one:
Code:
func({Float, bool, _}: x)
{
...
}
we may have a question about an actual tag of
x. In the tutor it is claimed that a following construct should be used:
Code:
func({Float, bool, _}: x, type_x = tagof x)
{
...
}
I checked this with a following combination:
Code:
public timed(id)
{
new Float: x = 3.0;
new bool: y = true;
new z = 4;
func1(x, y);
func1(y, y);
func1(z, y);
}
func1({Float, _}: a, type_a = tagof a)
{
new Float: flt, bool: bl, int;
switch(type_a)
{
case tagof(flt): log_amx "a is float";
case tagof(bl): log_amx "a is bool";
case tagof(int): log_amx "a is int";
}
}
The output looks like:
Code:
a is int
a is int
a is int
So, what is the right usage of
tagof?
Thanks.