[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
passing constants as "textual literals" to foreign-lambdas?
From: |
Al |
Subject: |
passing constants as "textual literals" to foreign-lambdas? |
Date: |
Mon, 4 Mar 2024 23:51:49 +0200 |
User-agent: |
Betterbird (Linux) |
Suppose that there is a C function
int result;
void compute( int x, int y /* several more */) {
result = /* some complex computations */ ;
}
I could get a hold of "result" using foreign-value, and I could declare
"compute" as a foreign-lambda. If I wanted to pass the constants x=3,
y=4 (plus some other variables) to compute(), csc would C_fix() the
constants then C_unfix() them to pass them to the "foreign lambda".
Is there any way to avoid the C_fix() / C_unfix() spiel and pass
constant values directly as textual literals to compute() -- more
exactly, to csc which in turn outputs the compute() calls in the
generated .c file?
Specifically, I have some offsets into a vector that are computed via
macros. The offsets vary between different invocations of the macros,
but are known at compile time. compute(), called from the macros,
operates on the vector at the given offsets (plus a variable
base-index). I would like to pass those constant offsets directly,
without generating useless (and slow) code to fix() / unfix() them.
The one work-around I can think of is to write an er-transformer macro
to generate strings for foreign-primitive / foreign-lambda*
specializations of compute() with certain constant args. This doesn't
seem so nice though.
Thanks,
Al
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- passing constants as "textual literals" to foreign-lambdas?,
Al <=