[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: |
Wed, 12 Nov 2008 15:15:10 +0100 |
User-agent: |
RoundCube Webmail/0.1-rc2 |
i considered using (system ...), too, but it depends on having access to
csc and a
way of finding the executable. making an interface to the compiler
available as a
library-unit eliminates these needs, though a C compiler (and libchicken)
would
still be required. the csc code should contain a way to find both on
all platforms.
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.
On Tue, 11 Nov 2008 23:13:02 -0600, Mark Fredrickson wrote:
> While this is probably not what you are looking for, there is always
> (system "csc -s path/to/file.scm"). This should help with issues of
> using (eval ...). You can (write ...) your code to a temp file, run
> csc on it, and (load ...) the .so.
>
> If you are trying to compile a closure, I'm not sure of a good way to
> make it happen, but I'd be interested to hear other input.
>
> I am at this very moment working on a similar problem (though I'm only
> compiling files not metaprogrammed code, so my situation may be easier).
>
> Good luck and report back if you find anything,
> -Mark
> On Nov 11, 2008, at 4:09 PM, Felix Lange wrote:
>
>> hi, chicken-users,
>>
>> i've been using chicken scheme for quite a while now, and would like
>> to request a feature (or at least a hint on doing something roughly
>> equivalent).
>>
>> most, if not all common lisp implementations provide the 'compile-
>> file and 'compile functions.
>> these are very useful for implementing domain-specific languages
>> (among other tasks).
>> having 'compile available at runtime makes it possible to compile
>> these languages into lisp code, which,
>> when it is run, executes at the same speed as everything else in the
>> running image.
>>
>> in scheme, since 'compile is not provided, i'd be building an
>> interpreter or, even worse,
>> use eval.
>>
>> as chicken is a scheme-to-C compiler, 'compile, if it were available
>> would probably return a string of C code (and should therefore be
>> called 'compile-to-c).
>> the output of 'compile-to-c could be written to a temporary file,
>> which in turn could be
>> compiled/linked by an external c compiler (assuming it's presence,
>> libtcc?) and loaded back into the running user program as a shared
>> library.
>>
>> example from dsl background (compilation might improve speed if some-
>> long-list is really really long):
>>
>> (define dl (dsl-code->lambda-form (quote ..... )))
>> (map (compile dl) some-long-list)
>>
>> a penny for your thoughts....