[plt-scheme] define-struct vs make-struct-type: struct type descriptor

From: Michael Forster (mike at sharedlogic.ca)
Date: Wed Jun 4 17:31:49 EDT 2008


I'm using v372, and I've defined tuple structure type as shown below.
I also want to define a constructor, foo, supplementary to make-foo
as make-list is to list.

#lang mzscheme
(define-struct foo (bar))
(define foo (lambda (bar) (make-foo bar)))

When I run this, I get the following:

Welcome to DrScheme, version 372 [3m].
Language: Textual (MzScheme, includes R5RS).
module: duplicate definition for identifier in: foo

If I use make-struct-type instead, following the style illustrated
in the Help Desk, as shown below, I don't get the collision
between identitiers.

#lang mzscheme
(define-values (struct:foo
  (make-struct-type 'foo #f 1 0))
(define foo (lambda (bar) (make-foo bar)))

My interpretation of the v372 Help Desk reference for define-struct
and make-struct-type is that these should be equivalent.  If so, why
does define-struct result in the definition of a foo identifier, while
make-struct-type does not?



Posted on the users mailing list.