Re: Expanding macros

2012-09-28 Thread Panicz Maciej Godek
Bonjour,

> There’s the ,expand command at the REPL.
>
> It’s implemented like this:
>
>   (define (repl-expand repl form)
> (let ((from (repl-language repl))
>   (opts (repl-compile-options repl)))
>   (decompile (compile form #:from from #:to 'tree-il #:opts opts
>   #:env (current-module))
>  #:from 'tree-il #:to from)))
>
> Psyntax, the macro expander, returns tree-il, hence the need to go
> through ‘decompile’.

Thanks a lot. By the way, the (undocumented, as of 2.0.5) decompile
function returns two values -- the first being the expanded expression
and the second -- #f.
As I've figured out from system/base/compile, the second return value
is the environment, but I've been wondering under what circumstances
would that value be different from #f.

Best regards
MG



Re: Module reflection and the list of bound symbols

2012-09-28 Thread Thien-Thi Nguyen
() Panicz Maciej Godek 
() Fri, 28 Sep 2012 19:37:17 +0200

   (Or maybe I just overlooked something, and they are already
   available?)

Check out ‘(ice-9 session) apropos’ to see what it does.  In Guile 1.4,
one of its subroutines:

(define apropos-fold-exported
  (make-fold-modules root-modules submodules
 (lambda (fob)
   (fob-info fob #:public-interface

uses ‘fob-info ... #:public-interface’, which was the result of long
past (but still memorably pleasant) "separation of concerns" hacking
(see ).
Anyway, the important bit is that "public-interface" derives from the
procedure ‘module-public-interface’, present in other Guile versions.

Probably you want to explore the ancestor of ‘fob-info ... #:obarray’,
instead, to access the full set of bindings (not just public), but i
didn't mention that because the code that uses it in Guile 1.4 ‘(ice-9
session)’ is long and the Guile module system is somewhat of a rats nest
[insert maniacal laughter, here :-D]...  Same thinking applies, however.

-- 
Thien-Thi Nguyen . GPG key: 4C807502
.  NB: ttn at glug dot org is not me   .
. (and has not been since 2007 or so)  .
.ACCEPT NO SUBSTITUTES .
... please send technical questions to mailing lists ...



pgpuM4KR3oQ7M.pgp
Description: PGP signature