Re: lambda-like expressions for C



>exactly why? fprintf does a close proximity to such a thing, and its used extr
>emely 
>heavily. I thought glib stood for 'generic lib' - and a lambda-like extension 
>to C is 
>pretty damn generic if done right.

either i just don't understand what you want to do, or you don't
understand enough about how a program in C (or C++ or any other
compiled-to-machine-code language) works when its executing.

when you write

     if (i < 50) fprintf (stderr, "something\n");

this expression is converted by the compiler into machine code. when
the processor actually executes it, it is simply marching through a
series of low-level instructions that cause it to do certain basic
things. it has no clue what the original line of text that you typed
was that ultimately ended up as this stream of instructions.

by constrast

   lambda ("if (i < 50) fprintf (stderr, \"something\n\")");

is a function call that passes a string to the function. this string
is just text, and cannot be executed by the current program without
first converting it to machine code. there are many ways of doing
that, but they are all very expensive, and would not be used
lightly. using them for debugging would be, uhm, unusual. the
"simplest" one is to just feed the string to a compiler and
dynamically link the resulting object. problem is: no context for the
variables can be provided. the most "complex" one requires a full C
interpreter, several of which exist, but again, the interpreter would
have no context for the variables that you are transferring from the
outer scope of the "lambda" expression.

so, as i said, either i am misunderstanding you or you don't seem to
grasp this basic level of program execution.

--p



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