Any

Any is a more informative and type-safe version of void pointer. 1

declaration

All value types can be implicitly cast to type Any.

x : Any = 3.0;
printf("x contains this float: %f\n", *cast(x.value_pointer, ^float));
x = "foo";
printf("now x contains this string: %s\n", *cast(x.value_pointer, ^string));

properties

Any is a type pointer for any type and a void pointer to the value. 2

  • type - pointer to a Type_Info struct with specific details about the assigned value type
  • value_pointer - void pointer to the value

  1. Any is a more informative and type-safe version of void pointer.
    “Demo: Run-Time (and Compile-Time) Type Information” YouTube, uploaded by Jonathan Blow, Feb 11, 2015, https://youtu.be/JoNkttD_MUs?t=754 

  2. Any is a type pointer for any type and a void pointer to the value.
    “Demo: Run-Time (and Compile-Time) Type Information” YouTube, uploaded by Jonathan Blow, Feb 11, 2015, https://youtu.be/JoNkttD_MUs?t=895 

jailang 2019 pixeldroid
https://github.com/pixeldroid/jailang
programming pages theme v0.5.21 (https://github.com/pixeldroid/programming-pages)