[Ur] FFI and transactions

Adam Chlipala adamc at impredicative.com
Sun May 29 13:17:54 EDT 2011


Robin Green wrote:
> I can't imagine an impure function which has a completely pure
> implementation. Examples of the reverse are easy to come up with, however.
>
> Can you give an example of when this might happen?
>    

I'm thinking of examples where you want to expose a library interface 
that allows impurity, even though your present implementation is pure.  
This would make sense only to enable forward compatibility.

>> Perhaps the piece you're missing is that abstract types in FFI modules
>> may be implemented with arbitrary C types, with no restrictions?  (They
>> may even be implemented with structs (not just struct pointers)!)
>>      
> Yes, I was indeed missing that. But... how does Urweb know how much stack
> space to allocate for them - does it parse the .h files? Or is there
> something about x86 calling conventions that I'm missing?
>    

The Ur/Web compiler works by generating C code to pass to GCC, so any 
library presentation via header files that works for normal C code will 
work for Ur/Web FFI libraries.



More information about the Ur mailing list