[Top][All Lists]

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

Re: %module-public-interface

From: Andy Wingo
Subject: Re: %module-public-interface
Date: Tue, 27 Apr 2010 22:34:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

Hi Ian,

On Fri 02 Apr 2010 02:11, Ian Hulin <address@hidden> writes:

> On 30/03/10 22:52, Ludovic � wrote:
>> Lilypond does:
>> --8<---------------cut here---------------start------------->8---
>>        mod = scm_call_0 (maker);
>>        scm_module_define (mod, ly_symbol2scm ("%module-public-interface"),
>>                           mod);
>> --8<---------------cut here---------------end--------------->8---
>> Solution: do something like:
>> --8<---------------cut here---------------start------------->8---
>>    scm_set_module_public_interface_x (mod, mod);
>> #else
>>    scm_module_define (mod, ly_symbol2scm ("%module-public-interface"),
>>                       mod);
>> #endif
>> --8<---------------cut here---------------end--------------->8---
>> (We just need to add that function.)

As it appears here that you are trying to export everything from that
module (in a somewhat incorrect formulation -- I can explain if you
like), and that seems to be a sort of pattern, I'd suggest that instead
we offer a module-export-all! function. Here is some code to provide
such a function for pre-2.0 guile:

      ((not guile-2)
       (define (module-export-all! mod)
         (define (fresh-interface!)
           (let ((iface (make-module)))
             (set-module-name! iface (module-name mod))
             ;; for guile 2: (set-module-version! iface (module-version mod))
             (set-module-kind! iface 'interface)
             (set-module-public-interface! mod iface)
         (let ((iface (or (module-public-interface mod)
           (set-module-obarray! iface (module-obarray mod))))))

Use that to export all bindings instead. As it is, there are some shims
for %module-public-interface hackery to keep on working if deprecated
code is compiled in, but you should migrate to calling
module-export-all!, I think.

Then your C code would unconditionally:

   scm_call_1 (scm_variable_ref (module_export_all_var), mod);



reply via email to

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