chicken-janitors
[Top][All Lists]
Advanced

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

Re: [Chicken-janitors] #548: autoload egg broken with newer chicken


From: Chicken Trac
Subject: Re: [Chicken-janitors] #548: autoload egg broken with newer chicken
Date: Tue, 24 Sep 2013 08:45:56 -0000

#548: autoload egg broken with newer chicken
-------------------------+--------------------------------------------------
  Reporter:  syn         |       Owner:  foof               
      Type:  defect      |      Status:  new                
  Priority:  minor       |   Milestone:                     
 Component:  extensions  |     Version:  4.6.x              
Resolution:              |    Keywords:  autoload global-ref
-------------------------+--------------------------------------------------

Comment(by alaric):

 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)))
 }}}

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/548#comment:5>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

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