Subject: Re: Free book for converting my C mind?
From: (Rob Warnock)
Date: Wed, 18 Feb 2004 02:44:32 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Marco Antoniotti  <> wrote:
| Since we are at it... :)
| What is the translation in Scheme of the Common Lisp
| 	(defstruct foo
| 	   (a 42 :type integer)
| 	   (b "foo" :type string))

As in the other example, it depends on what you restrict yourself to:

1. For either IEEE Scheme [IEEE Std. 1178-1990 (R2002)] or
   R5RS Scheme (1998): There is no translation. Standard Schemes
   do not include structures.

2. Specific implementation extensions: Many, various, idiosyncratic,
   some with typing and some not.

   For example, PLT DrScheme/MzScheme provides both simple untyped-slot
   structures <URL:
   mzscheme-Z-H-4.html>, for which the translation would be as follows
   [not shown is the single-inheritance case, where the first arg is a
   two-element list]:

	(define-struct foo a b)

   and typed-slot structures <URL:
   206p1/html/mzscheme/mzscheme-Z-H-4.html> with some "property" stuff
   I really don't understand, but if you define your own accessors you
   can associate an optional "guard-proc", which: called by make-struct-type before attaching the property
	to a new structure type. ... To reject a property association
	(e.g., because the value supplied to make-struct-type is
	inappropriate for the property), the guard can raise an exception.

   Maybe that can be used to enforce slot value typing, I dunno...


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607