chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Spiffy & OpenSSL in compiled code


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] Spiffy & OpenSSL in compiled code
Date: Thu, 04 Oct 2012 16:29:49 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/30/2012 12:43 PM, Andy Bennett wrote:

> The long term solution is to fix the autoload egg so that we can use
> that: Alaric has a similar requirement for Ugarit so it makes sense to
> put that functionality into an egg.

I currently have the following in ugarit:


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


I'd love to wrap it in macros that emulate the features of the autoload
egg, but I remain faintly daunted by writing complex macros. Would
anybody fancy taking on my get-bindings-from-module function above,
extending it to call an arbitrary closure in the error case rather than
just raising an error (as autoload provides facilities for using a
fallback rather than raising an error, which would be required for this
spiffy case), and wrapping it in an autoload macro?

http://api.call-cc.org/doc/autoload

Or at least giving me the impetus to figure it out myself :-)

ABS

- --
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlBtq20ACgkQRgz/WHNxCGrs3QCfaL0+xY7cciIDYr3fkQcCetBk
Ds0AoJDgZnqnPb5AlvIkLG6onW7pJfL4
=skuq
-----END PGP SIGNATURE-----



reply via email to

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