guile-devel
[Top][All Lists]
Advanced

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

Re: program-module returns a non-module


From: Andy Wingo
Subject: Re: program-module returns a non-module
Date: Mon, 06 Sep 2010 13:58:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi,

On Sun 05 Sep 2010 02:25, "Jose A. Ortega Ruiz" <address@hidden> writes:

>   (define cp (module-ref (current-module) 'cons))
>
>   (program? cp) => #t
>   (program-module cp) => #<pointer 0xb77ccbb0>
>   (module? (program-module cp)) => #f
>
> Since `cp' above is a program, i was expecting the return value to be
> always a module: is that a wrong expectation or is this a bug?

It's a bug.

When Guile compiles a Scheme function, it doesn't emit a constants table
unless it has to. It has to if there is a quoted constant in the
function body. The constants table is also used as a cache for toplevel
variable access.

If there is a constants table, index 0 of that table will contain the
procedure's module. 

However since primitives, full continuations, partial continuations, and
foreign functions all hand-craft their bytecode trampolines, the Scheme
compiler isn't involved, so it's not there to ensure that the 0th
element of the object table is a module. It's not even clear what it
means for a primitive procedure to have a module.

There could be many solutions -- for example, flagging programs loaded
via the load-program opcode as being "module-blessed" -- but I think for
now the simple heuristic of rejecting non-module returns from
program-module will suffice. I have committed that locally and will push
soon.

Thanks for the report,

Andy
-- 
http://wingolog.org/



reply via email to

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