Subject: Re: Tutorial on writing Macros?
From: (Rob Warnock)
Date: 26 Oct 2000 10:16:46 GMT
Newsgroups: comp.lang.scheme
Message-ID: <8t90ae$2uim6$>
Friedrich Dominicus  <> 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 like
| (define-record 'maybe-type (name "foo")
|         (first-name "bar")
|         age)

Actually, MzScheme (and thus DrScheme) *has* records, called structures
used this way:

	> (define-struct person (name first-name age))
	> (define my-name (make-person "foo" "bar" #f))
	> my-name
	> (person-name my-name)
	> (set-person-name! my-name "foz")
	> (person-name my-name)
	> (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)
	> (educated-person-name smarty)
	reference to undefined identifier: educated-person-name
	> (person-name smarty)

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

	> (person? smarty)
	> (person? my-name)
	> (educated-person? smarty)
	> (educated-person? my-name)


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