You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
foreign c {
include #<libanoma>
}
axiom readPre :String→Int;
compile readPre {
c ↦"readPre";
ghc ↦"readPre";
};
This currently works, as we just spit out a single C file (not included as I don't have wasi setup.).
However, if future plans change (say your compilation unit changes from the entire program, to each package, or maybe wish to do linking similar to OCaml to speed up compile times massively), this would not scale with it, as semantically the system doesn't know how things relate and what to bring into scope for another library who wishes to use this, so it may present problems.
Something like factor's or CL's Alien functionality may help.
! Missing FFI FunctionsLIBRARY: libcFUNCTION: c:int mprotect ( c:void* addr, c:size_t len, c:int prot )! Click on the url above to see how I use this!
I will note I'm not the most familiar with using FFI at this level, but these may help with future design around the problem. From what I understand these languages handle the FFI problem fairly decently
Also a follow up question: How does GC work in regards to foreign blocks, could GC make certain features of this hard to maintain or remove invariants that is relied upon.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently to include c code, it looks something like
or perhaps
This currently works, as we just spit out a single C file (not included as I don't have
wasi
setup.).However, if future plans change (say your compilation unit changes from the entire program, to each package, or maybe wish to do linking similar to OCaml to speed up compile times massively), this would not scale with it, as semantically the system doesn't know how things relate and what to bring into scope for another library who wishes to use this, so it may present problems.
Something like
factor
's orCL
's Alien functionality may help.https://docs.factorcode.org/content/article-alien.html
https://pmsf.eu/pub/cmucl/doc/cmu-user/aliens.html
https://cffi.common-lisp.dev/ (portability layer, has some interesting documents)
https://docs.factorcode.org/content/word-FUNCTION__colon__,alien.syntax.html
I use it in https://github.com/mariari/Misc-Stack-Scripts/blob/master/Factor/compiling-lisp/unary/unary.factor
I will note I'm not the most familiar with using FFI at this level, but these may help with future design around the problem. From what I understand these languages handle the FFI problem fairly decently
Also a follow up question: How does GC work in regards to foreign blocks, could GC make certain features of this hard to maintain or remove invariants that is relied upon.
Beta Was this translation helpful? Give feedback.
All reactions