unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: 12202@debbugs.gnu.org
Subject: bug#12202: psyntax defeats autoload
Date: Tue, 05 Mar 2013 17:45:21 +0100	[thread overview]
Message-ID: <87wqtlvlr2.fsf@pobox.com> (raw)
In-Reply-To: <87y5lhmowt.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 14 Aug 2012 18:14:26 +0200")

On Tue 14 Aug 2012 18:14, ludo@gnu.org (Ludovic Courtès) writes:

> (define-module (foo) #:autoload (does-not-exist) (baz))
> (define (chbouib) (baz))
> (pk 'hello)
>
> Trying to evaluate it fails this way:
>
> $ guile --no-auto-compile t.scm 
> Backtrace:
> In ice-9/boot-9.scm:
>
> [...]
>
>  292: 3 [get-global-definition-hook baz (hygiene foo)]
> In unknown file:
>    ?: 2 [module-variable #<directory (foo) b3b510> baz]
> In ice-9/boot-9.scm:
> 2732: 1 [b #<autoload (does-not-exist) b3b3f0> baz #f]
> In unknown file:
>    ?: 0 [scm-error misc-error #f ...]
>
> ERROR: In procedure scm-error:
> ERROR: missing interface for module (does-not-exist)
>
> ... which defeats the whole purpose of autoloads.
>
> What about something along these lines (untested)?

This is a great idea.  We should assume that autoloads are not macros.
Not sure we can change it in 2.0 though, because there could be uses of
autoloaded macros.

However your patch won't work:

> diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
> index 6c264a6..8a30f82 100644
> --- a/module/ice-9/psyntax.scm
> +++ b/module/ice-9/psyntax.scm
> @@ -289,15 +289,20 @@
>          (lambda (symbol module)
>            (if (and (not module) (current-module))
>                (warn "module system is booted, we should have a module" symbol))
> -          (let ((v (module-variable (if module
> +          (let ((m (if module
>                         (resolve-module (cdr module))
> -                                        (current-module))
> -                                    symbol)))
> +                       (current-module))))
> +            (case (module-kind m)
> +              ((autoload)
> +               ;; don't try to actually load the module
> +               #t)
> +              (else
> +               (let ((v (module-variable m symbol)))
>                   (and v (variable-bound? v)
>                        (let ((val (variable-ref v)))
>                          (and (macro? val) (macro-type val)
>                               (cons (macro-type val)
> -                              (macro-binding val)))))))))
> +                                   (macro-binding val))))))))))))
>  

because the module-kind of the module will never be `autoload' here.  As
you can see in your backtrace, the module-kind is `directory' -- the
autoload only ends up getting loaded while grovelling (foo)'s import
array.

Andy
-- 
http://wingolog.org/





  reply	other threads:[~2013-03-05 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 16:14 bug#12202: psyntax defeats autoload Ludovic Courtès
2013-03-05 16:45 ` Andy Wingo [this message]
2013-03-13  9:01   ` Andy Wingo
2013-03-14 13:21     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqtlvlr2.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=12202@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).