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


18.14.6 Mapping Functions

Struct fields can be of any type, and that includes function types or closures. This is especially useful to build interfaces.

For orthogonality, it is possible to map function types. The result of the mapping is not very useful though: mapping a function type results in a function with an empty body. If the function returns a value, a default value (zero for integral types, empty arrays for array types, etc) is returned.

Example:

(poke) type Fun = (int) int
(poke) Fun @ 0#B
#<closure>
(poke) (Fun @ 0#B) (10)
0x0