[comp.lang.scheme] structures - where are they?

bevan@cs.man.ac.uk (Stephen J Bevan) (12/18/90)

I'd like to define structures similar to defstruct in lisp or datatype
in ML.  How do I go about it in Scheme ?

I realise I could just use the structure extensions in which ever
Scheme I'm using (most seem to have them), but this isn't exactly
portable.

To give you a concrete example, how would I define the following
CommonLisp structure in Scheme :-

(defstruct Grammar
  (terminals)
  (non-terminals)
  (productions)
  (start)) 

I've tried just using a list/vector, but this cries out for a a
pattern matching command (like record-case in Chez Scheme or
destructure in T) to make accessing the elements easier.  If this is
the way to go, then how do I define a portable pattern matcher?

The other way I can think of is to use the lexical scoping mechanism
in some way to create functions which are bound in the scope of the
variables that make up the structure.  This is done in Abelson &
Sussman and in Dybvig, but they uses a cond to do function
dispatching, and I'd rather not have this overhead (ok so call be
picky).

Stephen J. Bevan		bevan@cs.man.ac.uk