-
-
Notifications
You must be signed in to change notification settings - Fork 9
Intrinsic Procedure __pass__
IsaacShelton edited this page Mar 21, 2022
·
1 revision
The __pass__ function can be used to perform operations on a value before it is passed to a procedure.
The __pass__ function can be declared as:
func __pass__(value POD TheType) TheType {
}
By default, children of struct-like values will automatically have their __pass__ function called within the parent __pass__ function. If this behavior is undesired, then it can be disabled by throwing the verbatim keyword out in front of the parent's __pass__ declaration.
struct Bomb ()
struct Bomber (a, b, c, d, e, f, g Bomb)
func __pass__(bomb POD Bomb) Bomb {
printf("BOOOOM!")
return bomb
}
verbatim func __pass__(bomber POD Bomber) Bomber {
// Since we used 'verbatim' keyword, none of the children of 'bomber' will
// have their '__pass__' called, and no message will be printed.
// If instead we didn't use the 'verbatim' keyword, then the boooom message
// would be printed for each child
return bomber
}
Note that the argument taken into __pass__ must be marked as POD. If it wasn't, then it would mean that __pass__ would be called before itself, which is illogical.