Re: lambda-like expressions for C



On Wed, 9 Apr 2003, Edward Peschko wrote:
> hey all,
> 
> I was wondering if anybody knew of a lambda-like expression api for
> C... what I'm looking for is something like:
> 
> int variable = 15;
> lambda ("if (_1 < 50) fprintf(stderr, \"HERE -- %d\", _1); ", variable);
> 
> where the first string would be evaluated at run-time, and execute the
> code, substituting the value in 'variable' for _1. (sort of like fprintf,
> except the strings that 'lambda' would take would support a subset of the
> c-api)
> 
> what I'm ultimately looking for is the ability to take this string from a
> file (or other source), and reconfigure what the program is doing on the
> fly, without recompiling.

This is pretty far from what a lambda does.  It's more like eval in Scheme,
and would involve run-time code generation, not a trivial task.  If you
look at `C (http://www.pdos.lcs.mit.edu/tickc/), you'll get some idea of
what's involved.  They don't allow run-time compilation of arbitrary code,
though, but I think their backend could be modified to work with it, and
they have a very fast backend.  

-Lars

-- 
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| Hårdgrim of Numenor
"I do not agree with a word that you say, but I   |----------------------------
will defend to the death your right to say it."   | Where are we going, and
    --Evelyn Beatrice Hall paraphrasing Voltaire  | what's with the handbasket?



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