guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Confusing problems with (ice-9 syncase) and sc-expand3.


From: Rob Browning
Subject: Confusing problems with (ice-9 syncase) and sc-expand3.
Date: 29 May 2001 23:39:51 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

(If you don't care about compilation, just skip down to the "However,"
 part where I describe the more general problem I'm having with the
 module/macro system.)

>From reading what little documentation there is in psyntax.ss
regarding sc-expand and sc-expand3, and looking at the usage in
syncase.scm, it seems like sc-expand3 may do what I need wrt to
getting expansions and evaluations to happen a the right time when
compiling via hobbit.

In particular, it looks like a call to 

  (sc-expand3 some-form 'c '(compile load eval))

Should do the right thing when some-form is an eval-when.  If the
eval-when specifies 'compile, then the form will be executed.  If the
form specifies 'load, then the form will be expanded and replaced so
it'll show up in the compiled output.  If the form only specifies
'eval, it will be ignored (according to the chezscheme docs, that's
the expected behavior.  'eval means only expand/evaluate the eval-when
form if you're evaluating from the prompt or loading a plain scheme
file (not a compiled object file) via load).

However, when I try to get this to work right, I get unexpected
behavior.  In particular, if I try to have a "compilation" module that
uses sc-expand3, it doesn't work right.  Client code can't just
(use-modules (test-compiler)).  They must also (use-modules (ice-9
syncase)).  This is true, even if I try and export *all* of syncase's
public symbols from the test-compiler module.  For example.  I have a
dummy module to demonstrate called rlb-dummy, and it just says:

  (define-module (ice-9 rlb-dummy))
  (use-modules (ice-9 syncase))

  ;; re-export all of syncase's public symbols
  (module-for-each
   (lambda (name binding)
     (display "Exporting ") (display name) (newline)
     (module-export! (current-module) (list name)))
   (module-public-interface (resolve-module '(ice-9 syncase))))

If you try to use it and then call sc-expand3, you'll get the wrong
answer until you also (use-modules (ice-9 syncase)) directly.

Any ideas why?

Thanks

Here's the full test run.  You can see that the answers unexpectedly
differ.

  guile> (use-modules (ice-9 rlb-dummy))
  Exporting fluid-let-syntax
  Exporting datum->syntax-object
  Exporting sc-expand3
  Exporting include
  Exporting syntax-case
  Exporting syntax-error
  Exporting identifier?
  Exporting bound-identifier=?
  Exporting sc-expand
  Exporting eval
  Exporting with-syntax
  Exporting letrec-syntax
  Exporting generate-temporaries
  Exporting eval-when
  Exporting syntax-dispatch
  Exporting sc-macro
  Exporting syncase
  Exporting void
  Exporting syntax-rules
  Exporting let-syntax
  Exporting free-identifier=?
  Exporting define-syntax
  Exporting install-global-transformer
  Exporting syntax
  Exporting syntax-object->datum
  Exporting identifier-syntax
  guile> (sc-expand3 '(eval-when (eval) (display 42) (newline)) 'c '(compile 
load eval))
  (eval-when (eval) (display (quote 42)) (newline))
  guile> (use-modules (ice-9 syncase))                                          
   guile> (sc-expand3 '(eval-when (eval) (display 42) (newline)) 'c '(compile 
load eval))
  (void)
  guile>  

-- 
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930



reply via email to

[Prev in Thread] Current Thread [Next in Thread]