power-struct
power-struct
7.0

power-struct

Kevin Robert Stravers

 (require power-struct) package: power-struct

Defines a struct form that implements default values and construction in an ergonomic manner.

Examples:
> (require power-struct)
> (power-struct X (#:a 10 #:b 20) #:prefab)
> (make-X #:b 9)

'#s(X 10 9)

> (X-a (make-X #:b 9))

10

Otherwise functions as a completely regular struct. The only difference is that we use keywords instead of ids.

syntax

(power-struct name maybe-super (kw-default ...) rest ...)

Defines a power-struct. The kw-default takes a single keyword and a default value. If the keyword is missing during construction in make-name, then the default value is used. Normal struct accessors like name-id are generated.