Hello,

I have some code like this:

---------------------------------
\def\MakeSomething{... some code that returns number 12}

\startluacode
function WorkWithSomething(data)
  -- call MakeSomething to obtain 12
  -- base on the value above make some decisions
end

WorkWithSomething(some_data)
\stopluacode
---------------------------------

If I use context.MakeSomething() inside the lua block, this is 
buffered till the end of the block, so I can't get the result and work with it.

If MakeSomething is a command already "edef-ed", I can use tokens.getters.macro.MakeSomething to find the value.

If MakeSomething has an argument which is determined within the 
lua block, then I can't use this hack.

The ugly partial solution I have found is to change the signature of 
WorkWithSomething to receive an argument and then I replicate the 
parameters of MakeSomething on the TeX side:

---------------------------------
\def\MakeSomething#1{...}

\startluacode
function WorkWithSomething(data,MakeSomethingOutput)
  -- we wanted to use some computation on data to obtain input to MakeSomething
  -- then call MakeSomething to obtain its result
end
\stopluacode

\ctxlua{WorkWithSomething(some_data, "\MakeSomething{replicate processing on data to obtain input to this macro}")}
---------------------------------

Is there a more elegant solution?
Ideally I want a way to start a TeX process under Lua, and
process the macros there before I get to the next line of Lua code.

In my motivation, MakeSomething is \datasetvariable. I wanted to look up
something in the dataset and use it for the rest of computation/typesetting.

Thanks a lot,
--Mohammad