![]() | ![]() | ![]() |
|
Hacks module, as the name suggests, provides various more or less ugly hacks. It serves as an escape from strict Gont typesystem.
int ptr_of('a x); | |
Return x coerced to integer. For complex types (structures, unions) it is address of object in the memory, hence the name. Returned value is not guaranteed to be positive, nor to be the same each time program is run. It is however guranteed to be the same each time it is called for phisically equal object. A and B are phisically equal if modifiction of A affects B. |
bool same_ptrs('a x, 'a y); | |
Same as ptr_of(x) == ptr_of(y). |
bool same_chars(char x, char y); | |
Same as same_ptrs(x, y). Will be removed when char gets to the compiler. |
int union_tag('a u); | |
Given arbitrary object u of union type, return its tag. Union tag is positive integer. Tags are assigned in ascending order, starting from 1, as fields of union are defined in source file. This function is unsafe if applied to something that is not an union. |
'a cast('b x); | |
Given x of type 'b return it, with type coerced to 'a. It is identity function. This function is unsafe. You shouldn't use it. |
bool is_null('a x); | |
Return true iff representation of x is same as representation of null. |