[plt-scheme] inferred name of struct instances

From: Doug Orleans (dougo at ccs.neu.edu)
Date: Tue Feb 4 14:58:52 EST 2003

I'm trying to assign a name to an applicable struct instance using
syntax-property, but it appears to be getting clobbered somehow by the
default struct naming mechanism:

(define-values (struct:fish make-anon-fish fish? fish-ref fish-set!)
  (make-struct-type 'fish #f 2 0 #f null #f
		    (lambda (f n) (fish-set! f 0 (+ n (fish-ref f 0))))))
(define-syntax (make-fish stx)
  (syntax-case stx ()
    ((_ . args)
     (begin (printf "Defining a fish called ~a.~%" (syntax-local-name))
	    (syntax-property (syntax/loc stx (make-anon-fish . args))
			     'inferred-name (syntax-local-name))))))
(define wanda (make-fish 12 'red))

> (load "fish.scm")
Defining a fish called wanda.
> wanda
> (object-name wanda)

What am I doing wrong?

--dougo at ccs.neu.edu

Posted on the users mailing list.