Handbook
Glossary
<struct-boa> ( class -- quot: ( ... -- struct ) )
Factor handbook
»
C library interface
»
Struct classes
»
Creating instances of structs
Prev:
<struct> ( class -- struct )
Next:
malloc-struct ( class -- struct )
Vocabulary
classes
.
struct
Inputs
class
a
class
Outputs
None
Word description
This macro implements
boa
for
struct
classes. A struct of the given class is constructed, and its slots are initialized using values off the top of the datastack.
See also
<struct>
,
malloc-struct
,
memory>struct
Definition
USING:
classes.struct.private
combinators
generalizations
kernel
sequences
;
IN:
classes.struct
MACRO:
<struct-boa>
( class -- quot: ( ... -- struct ) )
dup
struct-slots
[
length
]
[
[
(writer-quot)
[
[
over
]
]
dip
compose
]
map
]
bi
[
[
(struct)
]
curry
]
2dip
[
[
ndip
]
2curry
]
dip
[
spread
]
curry
compose
;