A constructor was a static function per variant. One taking an array field cannot exist, its parameter being a pointer, and building some variants in place and others by call would make two kinds of constructor. In place, every one is a constant where one is wanted, an lvalue a method can take the address of, and nothing a pub sum has to paste into its importer. What the function did for free is done here instead: arity is checked, since a short compound literal zero-fills quietly, and an argument is converted against its field's closure type. The price is that a constructor is no longer a function value; a lambda makes one.
49 lines
744 B
Scheme
49 lines
744 B
Scheme
(module types
|
|
(add-struct
|
|
add-union
|
|
add-enum
|
|
add-typedef
|
|
add-define
|
|
|
|
type-match
|
|
type-pattern-matches?
|
|
map-fields
|
|
|
|
add-sum!
|
|
get-sum
|
|
add-constructor!
|
|
get-constructor
|
|
variant-fields
|
|
reset-declarations!
|
|
|
|
add-spec!
|
|
get-spec
|
|
spec-parameter
|
|
spec-methods
|
|
add-realization!
|
|
realizes?
|
|
normalize-fields
|
|
|
|
add-method!
|
|
get-method
|
|
qualify-op
|
|
ops-key
|
|
|
|
add-name-type!
|
|
get-name-type
|
|
type-of
|
|
current-type-of
|
|
get-return-type
|
|
|
|
get-type-info
|
|
get-tag-info
|
|
get-fields
|
|
get-underlying-type
|
|
|
|
type-head?
|
|
named-arg?
|
|
typedef-name?
|
|
array-bound?
|
|
array-element-type)
|
|
"types.scm")
|