defstruct.hlp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. DEFSTRUCT - "Structure" definition facility.
  2. --------------------------------------------
  3. A more complete description, including examples, is in Defstruct.Doc.
  4. Defstruct( name-and-options:{id,list}, [slot-descs:{id,list}] ): id fexpr
  5. ---------------- -- ---- ---------- -- ---- -- -----
  6. Defines a record-structure data type. A general call to defstruct
  7. looks like this: (in RLISP syntax)
  8. defstruct( struct-name( option-1, option-2, ... ),
  9. slot-description-1,
  10. slot-description-2,
  11. ...
  12. ); % (The name of the defined structure is returned.)
  13. where slot-descriptions are:
  14. slot-name( default-init, slot-option-1, slot-option-2, ... )
  15. Option lists and default-init forms are optional and may be omitted.
  16. Some options have optional argument lists.
  17. A call to a Constructor macro has the form:
  18. MakeThing( slot-name-1 value-expr-1,
  19. slot-name-2 value-expr-2,
  20. ... );
  21. The Alterant macro calls have a similar form:
  22. AlterThing( thing,
  23. slot-name-1 value-expr-1,
  24. slot-name-2 value-expr-2,
  25. ... );
  26. A call to a Creator macro has the form:
  27. CreateThing( slot-value-1, slot-value-2, ... );
  28. Structure Options and arguments:
  29. Structure macro renaming, arg of NIL to suppress macro definition.
  30. !:Constructor name % Default: MakeThing
  31. !:Alterant name % Default: AlterThing
  32. !:Predicate name % Default: ThingP
  33. !:Creator name % Default: CreateThing
  34. Common prefix on selector/depositor names.
  35. !:Prefix idOrString % Dedfault: ""
  36. !:Prefix % If no arg, Struct name is prefix.
  37. Inclusion of substructures.
  38. !:Include structName % Starts with slot defns of subtype.
  39. !:IncludeInit initList % slot-name(default-init) list to merge
  40. % with default-init forms of subtype.
  41. Slot Options:
  42. !:Type typeId % Asserts the type of the slot.
  43. Override selectors/depositors with user-supplied fns.
  44. !:UserGet % fn name is [prefix]slot-name.
  45. !:UserPut % fn name is Put[prefix]slot-name.
  46. Miscellaneous functions on types:
  47. DefstructP( NAME:id ): extra-boolean expr
  48. ---- -- ------------- ----
  49. is a predicate that returns non-NIL (the Defstruct definition) if NAME
  50. is a structured type which has been defined using Defstruct, or NIL if
  51. it is not.
  52. DefstructType( S:struct ): id expr
  53. - ------ -- ----
  54. returns the type name field of an instance of a structured type, or
  55. NIL if S cannot be a defstruct type.
  56. SubTypeP( NAME1:id, NAME2:id ): boolean expr
  57. ----- -- ----- -- ------- ----
  58. returns true if NAME1 is a structured type which has been !:Included in
  59. the definition of structured type NAME2, possibly through intermediate
  60. structure definitions. (In other words, the selectors of NAME1 can be
  61. applied to NAME2.)