(defstruct name ..field-name ..clause)
  name: a sym
  field-name: zero or more syms
  clause: zero or more forms
  returns a class

Defines a struct.

defstruct is syntax sugar for defclass. It defines a class with all of the specified fields, along with:

To keep structs simple, their class clauses may only be const, met or prop. Classmacros, mixins, states, wrappers, field patterns and field initializers are not supported.

(defstruct Rect
  x y w h

  (met area ()
    (* @w @h)))

(let r (Rect:new 0 0 10 10))
(let s (Rect
  (x 2)
  (y 2)

(prn (.area s)) ; prints 100
(prn (Rect? s)) ; prints #t
(let t (clone s))
(prn (eq? s t) (same? s t)) ; prints #t #f