On Wed, Sep 15, 2010 at 2:01 AM, Felix
<fe...@call-with-current-continuation.org> wrote:
> From: Alex Shinn <alexsh...@gmail.com>
> Subject: Re: [Chicken-users] Autoloading optional dependencies
> Date: Wed, 15 Sep 2010 00:16:11 +0900
>
>> The only problem with this is you'll get warnings about
>> importing undefined identifiers.  I don't suppose we could
>> have a declaration or some way to suppress these warnings
>> for individual identifiers and/or modules?
>
> Sorry, I don't understand.

Well, let's say we have

(module auto (json-write)
  (import scheme)
  (autoload json json-write))

which basically just exports json-write
from the json egg but loaded on demand.
So the autoload could expand into:

(module auto (json-write)
  (import scheme)
  (begin
    (import (rename json (json-write tmp)))
    (define (json-write . args)
      (require 'json)
      (set! json-write tmp)
      (apply tmp args))))

thus making use of the module system to
resolve names, but performing the require
only once when json-write is first called.

This works and uses no deprecated features,
but when you use the module you'll get the
following warnings:

Warning: the following toplevel variables are referenced but unbound:
  json#json-write (in json-write)
  json#json-write (in json-write)

and rightly so, because it's a common error to
import an egg without requiring it.  But in this
case it's intentional.  So maybe we could have
an alternate form

  (import-without-warnings (rename (json (json-write tmp))))

?

-- 
Alex

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to