chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] undefined references in egg


From: Peter Bex
Subject: Re: [Chicken-users] undefined references in egg
Date: Fri, 8 Nov 2013 18:50:58 +0100
User-agent: Mutt/1.4.2.3i

On Fri, Nov 08, 2013 at 10:42:10AM -0700, Alan Post wrote:
> Running chicken-install, I get the following warning and error:
> 
>   Warning: reference to possibly unbound identifier `bar' in:
>   Warning:    foo
> 
>   Error: module unresolved: t
> 
> Reading the code, it seems the above warning is converted to a
> fatal error, though there may be cases where it does not.

Yeah, the warnings are normal Scheme warnings which you'd get in
regular compilation units.  However, the module system can't handle
unresolved references so it'll error out.

> Here is my problem:
> 
> I have an egg that, while initializing, defines bar, but bar isn't
> defined at compile-time, so I'm getting this error.  This works
> when I compile the code outside of a module, but there seems to be
> an additional constraint when I wrap it around (module ...).

What you're asking does not make sense in the presence of a module
system.  No module can define an identifier "into" another module
(at least, not without relying on weird implementation details).

A simple way to fix this is to provide BAR as a "hook" which
the module exposes, and expects another module to implement:

(module foo (foo bar)
  (import chicken scheme)

  (define bar (parameter (lambda _ (error "Hook not implemented"))))

  (define (foo) ((bar))))


(module something-else ()
  (import chicken scheme foo)
  (bar (lambda () 42)))

You can also use the "functors" module syntax if you want to get fancy:
https://wiki.call-cc.org/man/4/Modules#functors

Cheers,
Peter
-- 
http://www.more-magic.net



reply via email to

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