-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Foreign function interface and C API #43
Comments
I think this would be great, thanks for proposing it. |
I think the (ccall "gensym") (ccall "gensym" "if") @abrassel If you need some help, I can also help implementing some parts later this weekend. |
I also like the |
How is thing feature going? I am also interested. Is there a branch created for this? |
I'm currently designing the C API part to rewrite the |
OK let me know after you push the branch. I'd like to help. I am very comfortable programming in C. |
Ethan Hickman and I are also working on this. |
@8tx7K38ej1aBTKWK what's the current state of this? Would appreciate a brief overview of what you've done and what you would like to see implemented to wrap up this feature. |
If we want to wrap up this feature, the quickest option is I'll give a high-level description of For example, if we have (ccall "func" a b c) The three arguments should be evaluated and pushed onto the
Similar to Then, mov rdi, 3 ; argc
mov rsi, rsp ; argv
; pad stack
call func
; unpad stack This should be enough to implement the |
It would be nice to have a way to call C functions directly in Villain. For example,
where
add
is defined in C asOr maybe we could use
argc
,argv
similar to Janet's C API so we can have variable arity functions.Then we can implement many of the special forms as stdlib functions, such as
gensym
,string->symbol
, etc.This makes it trivial to add new features such as printing strings, loading dynamic libraries (
dlopen
), or maybe GUIs, etc.We also need to define some API in C to box and unbox values in Villain, which are simply
int64_t
,This is probably going to be a large feature, so I'll break it up into several parts:
ccall
function, collect extern labels, and pass arguments according to ABI or withargc
andargv
gensym
,string->symbol
to stdlib functions.Possible improvements:
argc
andargv
The text was updated successfully, but these errors were encountered: