Subject: Re: Tutorial on writing Macros?
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 26 Oct 2000 10:16:46 GMT
Newsgroups: comp.lang.scheme
Message-ID: <8t90ae$2uim6$1@fido.engr.sgi.com>
Friedrich Dominicus  <frido@q-software-solutions.com.NO-spam> wrote:
+---------------
| So my question is where can I find a bit more information on writing
| Macros in DrScheme.
+---------------

Well, this answer doesn't help that, but it may help your other problem...

+---------------
| What I want to do is hopefully not too difficult. In Standard Scheme
| records are not available I now would like to write s.th like
| 
| (define-record 'maybe-type (name "foo")
|         (first-name "bar")
|         age)
+---------------

Actually, MzScheme (and thus DrScheme) *has* records, called structures
<URL:http://www.cs.rice.edu/CS/PLT/packages/doc/mzscheme/node40.htm>,
used this way:

	> (define-struct person (name first-name age))
	> (define my-name (make-person "foo" "bar" #f))
	> my-name
	#<struct:person>
	> (person-name my-name)
	"foo"
	> (set-person-name! my-name "foz")
	> (person-name my-name)
	"foz"
	> (struct->vector my-name)	; useful for debugging
	#4(struct:person "foz" "bar" #f)
	> 

It also provides sub-types of a sort (though note that new sub-type
accessor names are *not* automatically defined for parent slots):

	> (define-struct (educated-person struct:person) (highest-grade))
	> (define smarty (make-educated-person "joe" "blow" 27 "PhD"))
	> (educated-person-highest-grade smarty)
	"PhD"
	> (educated-person-name smarty)
	reference to undefined identifier: educated-person-name
	> (person-name smarty)
	"joe"
	> 

Sub-structs satisfy the parent type predicates, but not the reverse:

	> (person? smarty)
	#t
	> (person? my-name)
	#t
	> (educated-person? smarty)
	#t
	> (educated-person? my-name)
	#f
	> 


-Rob

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043