Summary

autoload egg broken with newer chicken

Metadata

Attachments

Description

At least with Chicken 4.6.5 (and probably some versions before that) the autoload egg is broken because it uses global-ref. A work-around is unknown--can such functionality be implemented without global-ref at all?

Changes and comments

[2011-03-31 11:34:52 UTC] felix removed milestone 4.7.0

[2011-08-17 14:43:16 UTC] syn wrote:

The attached patch makes autoload work with newer Chickens again and should also be downwards compatible. However, it will emit notes about unbound toplevel variables when used interactively in csi. I guess that's not a big issue though.

[2011-08-17 14:43:39 UTC] syn attached get-rid-of-global-ref.patch (description=#f)

[2011-08-17 14:47:24 UTC] syn wrote:

OK, that approach does not work when autoload is used in modules unfortunately.

[2013-09-23 11:06:23 UTC] syn wrote:

Although the use of global-ref was removed, the autoload form now only works when the referenced module is actually available, i.e. it is not possible to autoload modules from eggs which aren't installed. Is this intended behavior? If so we can close this ticket.

[2013-09-24 10:45:56 UTC] alaric wrote:

I don't know about the egg author's intended behaviour, but for me, it's certainly not helpful behaviour :-) I originally used the autoload egg in Ugarit to support optional dependencies; eg, if the user (at run time) selected AES encryption, then it would attempt to use the aes functions, causing run-time auto-loading of the aes egg. But the code could compile and run fine if AES wasn't installed, as long as you didn't ask to use aes. This is a convenient and simple way to support optional dependencies.

Due to autoload no longer functioning in that way, I was forced to hack together my own autoload-esque mechanism for Ugarit. However, it doesn't support all the features of autoload, and doesn't have a nice wrapper macro, it's just the bits I need:

 #!scheme
  (define (get-bindings-from-module egg module bindings)
    (let* ((vektor (gensym))
           (rekuire-extension (gensym))
           (expression
            `(module ,(gensym) ()
                     (import
                      (rename
                       (only scheme vector require-extension quote) ; quote shouldn't need to be here
                       (vector ,vektor) (require-extension ,rekuire-extension)))
                     (,rekuire-extension ,module)
                     (,vektor ,@bindings))))
      (handle-exceptions
       exn (if ((condition-predicate 'syntax) exn)
               (signal (make-composite-condition
                        (make-property-condition 'exn
                                                 'message
                                                 (sprintf "This feature depends upon the optional module ~a being installed. Please install it with 'chicken-install -s ~a'." module egg))
                        (make-property-condition 'unsupported-feature
                                                 'egg egg
                                                 'module module
                                                 'bindings bindings)))
               (signal exn))
       (eval expression))))
 
  ;; FIXME: Write a macro to generate these for us.
 
  (define (autoload-lzma!)
    (let ((real-bindings
           (get-bindings-from-module 'lzma 'lzma '(compress decompress))))
      (set! lzma:compress (vector-ref real-bindings 0))
      (set! lzma:decompress (vector-ref real-bindings 1))))
 
  (define lzma:compress
    (lambda args
      (autoload-lzma!)
      (apply lzma:compress args)))
 
  (define lzma:decompress
    (lambda args
      (autoload-lzma!)
      (apply lzma:decompress args)))

[2013-09-24 10:47:24 UTC] alaric wrote:

Gah, I failed to format my code correctly. Let's just use the pastebin:

http://paste.call-cc.org/paste?id=752dd0e1667a1d7ffbda53d05df847c89a6e2e75

[2016-08-02 20:37:40 UTC] sjamaan wrote:

I fixed this with autoload 3.0 in [[33550]|] / [[33551]|]

[2016-08-02 20:37:40 UTC] sjamaan changed status from new to closed

[2016-08-02 20:37:40 UTC] sjamaan set resolution to fixed