[Larceny-users] [long] identifier bindings and visibility across phases

Marco Maggi marco.maggi-ipsu at poste.it
Tue Oct 6 14:36:31 EDT 2009


I have written:
> I  have   prepared  an  archive  of   test  files[1]  with
> everything  in  it,  which  can  be  downloaded  from  the
> "Downloads" page of Nausicaa[2].

I admit  that there is  too much code  in the archive,  so I
reduced it to the following:

(library (sublib)
  (export %bury %disinter)
  (import (rnrs))
  (define *objects*
    (make-eq-hashtable))
  (define (%bury key obj)
    (hashtable-set! *objects* key obj))
  (define (%disinter key)
    (hashtable-ref *objects* key #f)))

(library (lib)
  (export define-thing thing)
  (import (rnrs) (for (sublib) expand))
  (define-syntax define-thing
    (lambda (stx)
      (syntax-case stx ()
	((_ ?key ?id)
	 (begin
	   (%bury (syntax->datum #'?key) #'?id)
	   #'(define dummy #f))))))
  (define-syntax thing
    (lambda (stx)
      (syntax-case stx ()
	((_ ?key)
	 (with-syntax ((obj (%disinter (syntax->datum #'?key))))
	   #'(obj)))))))

(library (def)
  (export)
  (import (rnrs) (lib))
  (define (woppa) 123)
  (define-thing woppa woppa))

;;;; the program follows
(import (rnrs) (def) (lib))
(write (thing woppa))
(newline)

which  works for Ikarus  and (somewhat)  for Mosh,  while it
fails with  Ypsilon (my  original code worked  with Ypsilon,
too); with Larceny, running the program prints:

------------------------------------------------------------
Syntax violation: invalid reference

No binding available for woppa in library (...program...)

Form: woppa

Trace:

  (woppa)

  (thing woppa)

  (write (thing woppa))


Error: no handler for exception #<record &compound-condition>
Compound condition has these components:
#<record &who>
    who : "invalid reference"
#<record &message>
    message : "No binding available for woppa in library (...program...)"
#<record &syntax>
    form : woppa
    subform : #f

Terminating program execution.
------------------------------------------------------------

now, DEFINE-THING  stores a syntax object  into a hashtable,
and THING retrieves it; by changing the code in the (sublib)
library to:

  (define (%bury key obj)
    (write 'bury)(newline)
    (hashtable-set! *objects* key obj))
  (define (%disinter key)
    (write 'disinter)(newline)
    (hashtable-ref *objects* key #f)))

I see that  "bury" and "disinter" are printed,  so the error
seems to  come from bad insertion of  the disinterred syntax
object in the output form of the THING macro use.  Why is it
so?

TIA
--
Marco Maggi



More information about the Larceny-users mailing list