Creating instances of structs - Factor Documentation (original) (raw)

Structs can be allocated with new- and boa-like constructor words. Additional words are provided for building structs from C memory and from existing buffers:
( class -- struct )
( class -- quot: ( ... -- struct ) )
malloc-struct ( class -- struct )
memory>struct ( ptr class -- struct )

When the contents of a struct will be immediately reset, faster primitive words are available that will create a struct without initializing its contents:

(struct) ( class -- struct )

(malloc-struct) ( class -- struct )

Structs have literal syntax, similar to T{ for tuples:

S{