Next: , Previous: , Up: Types   [Contents][Index]


20.6.2 The any Type

Poke supports polymorphism with the any type. This type is used in contexts where a value of any type is allowed. For example, this is how you would declare a function that prints the size of any given value:

fun print_size = (any value) void:
{
  printf "%v\n", any'size;
}

The rules for handling any values are simple:

This means that using any operator that require certain types with any values will fail: you have to cast them first. Example:

(poke) fun foo = (any v) int: { return v as int; }

Arrays of any, any[], are also supported: