[Ur] callbacks from the c ffi

Adam Chlipala adamc at csail.mit.edu
Fri Sep 28 07:43:15 EDT 2012


On 09/27/2012 09:36 PM, Greg Samsa wrote:
> I've been happily playing with Ur/Web and am pleased with the results so far.  One problem I am stuck on however is creating a callback from Ur, in other words, calling a C function that can then call Ur functions.  Unless I am misreading the docs this doesn't seem to be currently supported.
>
> In looking at the generated C code, the api's generated are very straight forward, would it be possible to simply call those from a C function or would this have unintended consequences?
>    

Glad to hear you're happy so far. :)

You're right that there is no documented support right now for calling 
Ur functions from C.  One big impediment is that function names are 
"mangled" in a way that is intentionally unspecified and 
nondeterministic, so it will not be easy to predictably identify an Ur 
function from C.

You would certainly need to understand Ur region-based memory management 
to call Ur functions safely.

Can you fill us in more on your big-picture context?  Why do you want to 
call Ur functions from C?



More information about the Ur mailing list