GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Try online
  • GitLab
  • GitHub

This view

  • Original page
  • New address

GeezerVison is showing urn-lang.com — data/struct | Urn

data/struct

(defstruct name &clauses)

Macro defined at lib/data/struct.lisp:142:2

Define a struct called NAME.

NAME can be either a symbol or a list of three elements, whose elements name, respectively, the type (returned from type and used in defmethod, for instance), the constructor’s name, and the predicate’s name. In case NAME is a symbol, the constructor and predicate names are automatically derived from that symbol.

Consider:

(defstruct thing ...)
(defstruct (other-thing make-something-else is-something-else?) ...)

The first struct declaration generates a constructor called make-thing and a predicate called thing?, but the second declaration generates a constructor called make-something-else and a predicate is-something-else?.

The CLAUSES argument to defstruct controls the contents of the generated structure.

The (fields field ...) clause defines the fields of the structure type. Each field must be of one of the following forms:

  • field-name
  • (immutable field-name [getter-name])
  • (mutable field-name [getter-name setter-name]) Where a field in square brackets is optional. If no name is specified for the getter, it will have the name struct-field, while the setter will have the name set-struct-field!.

The (constructor tag fun) clause will use fun as the constructor for the structure type. tag will be a symbol in fun’s scope that builds the structure according to the fields clause.

Tutorial

  • An Introduction to Urn
  • Guess the number
  • Finding errors
  • Macros and more
  • How do I do X?
  • Integrating with Lua
  • The compiler API

Reference

  • Syntax
  • Special forms
  • CLI
  • The REPL

Recent News

  • Version 0.7.0 released
  • Version 0.6.1 released
  • Version 0.6.0 released

All libraries

  • Symbol index
  • compiler/helpers
  • compiler
  • compiler/nodes
  • compiler/optimise
  • compiler/pass
  • compiler/pattern
  • compiler/resolve
  • control/comparison
  • control/prompt
  • control/setq
  • core/base
  • core/binders
  • core/demand
  • core/list
  • core/match
  • core/method
  • core/prelude
  • core/string
  • core/symbol
  • core/table
  • core/type
  • data/alist
  • data/bitset
  • data/format
  • data/function
  • data/graph
  • data/set
  • data/struct
  • io/argparse
  • io/foreign
  • io
  • io/term
  • lua/basic
  • lua/bit32
  • lua/coroutine
  • lua/debug
  • lua/io
  • lua/math
  • lua/os
  • lua/package
  • lua/string
  • lua/table
  • lua/utf8
  • luajit/bit
  • luajit/ffi
  • luajit/jit
  • math/bignum
  • math/bit32
  • math/complex
  • math
  • math/matrix
  • math/numerics
  • math/rational
  • math/vector
  • prelude
  • test/assert
  • test/check
  • test
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.