wu-lang/wu

how to let the compiler know, that a function exists

w1kee opened this issue · 2 comments

w1kee commented

hey, i wanna develop dynamic redbean applications with wu. is there a way to let the compiler know a function exists without providing an implementation that will be compiled?

Hi! Yep it's possible:

myfoo: extern fun(args) -> return

You can see it in action in the Lua std binding https://github.com/wu-lang/std/blob/master/init.wu

There are some limitations to the return types, currently there's no way to express multivalue returns, as you can see in the Lua std bindings, so if you have those you'll need to use ...? (zero or more of any type) or ... (one or more) as the return type

Also, if you have to refer to nested methods or objects somewhere, you can use the form

myfoo: extern fun(args) -> return = "some.module.path.method"

https://github.com/wu-lang/std/blob/master/math.wu