chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Autoloading optional dependencies


From: Alex Shinn
Subject: Re: [Chicken-users] Autoloading optional dependencies
Date: Wed, 15 Sep 2010 10:35:24 +0900

On Wed, Sep 15, 2010 at 2:01 AM, Felix
<address@hidden> wrote:
> From: Alex Shinn <address@hidden>
> 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



reply via email to

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