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: Alan Post
Subject: Re: [Chicken-users] undefined references in egg
Date: Fri, 8 Nov 2013 10:56:05 -0700

On Fri, Nov 08, 2013 at 06:50:58PM +0100, Peter Bex wrote:
> 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
> 

Thank you Peter, that makes sense.  My case will be served by
parameterizing my currently undefined variables like you suggest.
Well, assuming the core team gets my patch for the posix unit
committed.

-a
-- 
my personal website: http://c0redump.org/



reply via email to

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