[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] using the compiler at runtime
From: |
Felix Lange |
Subject: |
Re: [Chicken-users] using the compiler at runtime |
Date: |
Thu, 13 Nov 2008 11:47:50 +0100 |
User-agent: |
RoundCube Webmail/0.1-rc2 |
thank you very much,
this isn't really what i had in mind, but it gets the job done.
<rant>
csc.scm already has (run-compilation) and (run-translation), though these
would need to be
refactored to take arguments and not depend on global variables.
writing compile-file would be a snap, then, but modularising the
implementation of csc probably
isn't a simple task. same goes for chicken.scm, the code isn't separated
into interface and implementation.
i'd throw myself in as a volunteer....
</rant>
is anything like this planned for chicken 4?
>> the whole thing boils down to implementing a library interface to csc.
>> compiling closures won't work, of course, but i think (compile-file ...)
>> would be enough for most tasks.
>>
>
> You mean something like this?
>
> ;;;; cf.scm
> ;
> ; to use it:
> ;
> ; csc -s cf.scm
> ; csi cf.so
>
> (use utils data-structures)
>
> #>
> #ifndef C_INSTALL_BIN_HOME
> # define C_INSTALL_BIN_HOME NULL
> #endif
> <#
>
> (define compile-file
> (let* ((binpath
> (or (and-let* ((p (getenv "CHICKEN_PREFIX")))
> (make-pathname p "bin") )
> (foreign-value "C_INSTALL_BIN_HOME" c-string) ) ) ; ugly, we
> need another way
> (csc (make-pathname binpath "csc")))
> (lambda (filename . opts)
> (let ((tmp (create-temporary-file "so")))
> (system*
> "~a -s '~a' -o '~a' ~a"
> csc filename tmp
> (string-intersperse opts " "))
> (on-exit
> (lambda ()
> (system (sprintf "rm -f '~a'" tmp))))
> (load tmp) ) ) ) )