(index ("define-datatype" 0) ("cases" 809))
(def (sig (syntax "(define-datatype TYPENAME [PREDICATE] VARIANT ...)" (id define-datatype))) (p "Defines a record type named " (tt "TYPENAME") ", where " (tt "VARIANT ...") " defines one or more constructors for instances of this type. " (tt "VARIANT") " should be of the form") (pre " VARIANT = (CONSTRUCTOR (FIELDNAME FIELDPRED) ...)") (p (tt "CONSTRUCTOR") " is the name of a constructor procedure that will be defined with as many arguments as fields are specified. " (tt "(FIELDNAME FIELDPRED) ...") " specify the name for each field and a procedure of one argment that should return a true value for legal field values.") (p "The optional " (tt "PREDICATE") " should be the name of a procedure that will be defined and which returns " (tt "#t") " when applied to an instance of this variant record."))
(def (sig (syntax "(cases TYPENAME EXP CLAUSE ...)" (id cases))) (p "A facility for matching and deconstructing the instance " (tt "EXP") " of the variant record with the name " (tt "TYPENAME") ". Each " (tt "CLAUSE") " specifies a constructor with field-names and a body to execute when the constructor matches the record instance:") (pre " CLAUSE = (CONSTRUCTOR (FIELDNAME ...) BODY ...)\n        | (else BODY ...)"))
