Next: str-exa, Previous: str-etr, Up: lib-structs [Contents][Index]
structs
type
system by looking inside foreign terms to get the address, or use
functor/3
to get the type. This has two negative effects: firstly, if
the structs
package should change its representation of foreign terms, then
your code will not work. But more importantly, you are more likely to
get type mismatches, and likely to get unwrapped terms or even doubly
wrapped terms where you expect wrapped ones.
fred(123456)
is not of type fred
, but a
pointer to fred
. Looked at another way, what resides in memory at
address 123456 is of type fred
.
pointer(opaque)
because you want to
view that pointer to be opaque, when you get something of this
type, then it will be printed as opaque(456123)
. This is not very
informative. It is better to declare
fred = opaque, thing = struct([…, part:pointer(fred), … ]).
so that when you get the contents of the part
member of a thing
, it is
wrapped as fred(456123)
.