[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [plt-scheme] define-structure question
At Wed, 12 Jun 2002 10:29:18 +1000, Chris Wright wrote:
> The help desk entry for define-structure isn't clear to me, and an example
> would help.
Well, the documentation was wrong and the implementation was broken.
I've committed repairs to the CVS repository, including a patch to the
test-suite hole.
> (define-structure (name-identifier field ...)) SYNTAX
There should have been two cases:
(define-structure (name-identifier field-identifier ...))
(define-structure (name-identifier field-identifier ...)
((init-field-identifier init-expr) ...))
In other words, fields with initialization expressions are declared
between a second set of parentheses.
Here's an example:
> (define-structure (add left right) ([sum (+ left right)]))
> (add-sum (make-add 3 6))
9
but unless you're using CVS, that won't work until v200 is released.
Matthew