objexp1.scm 397 B

123456789101112
  1. (define (object-with-closure c-name)
  2. (let ((opt (lambda ()
  3. (object (<java.lang.Object>)
  4. ((toString) ::java.lang.String
  5. (format #f "opt[~a]" c-name))
  6. ((fun) ::void
  7. (display c-name))))))
  8. opt))
  9. (define obj (object-with-closure '.x.c))
  10. (format #t "object: ~w -> ~w~%" obj (obj))
  11. ;; Output: object: #<procedure opt> -> opt[.x.c]