Replies: 2 comments
-
@dbrattli For the few bindings I've done for Rust so far, I've mostly used [<Erase; Emit("std::time::Duration")>]
type Duration =
abstract as_millis: unit -> uint64
abstract as_secs_f64: unit -> float Not sure if that helps you or not. I agree it would be nice to try to have a more standardized approach to bindings across all languages. |
Beta Was this translation helpful? Give feedback.
-
We've gone through the discussion about using always interfaces for the bindings and unfortunately the conclusions are split in different issues, but I can try to summarize from memory:
So in your first example @dbrattli you could use: [<ImportAll("json")>]
type json =
static member dumps(item: obj): string = nativeOnly
static member loads(json: string): obj = nativeOnly |
Beta Was this translation helpful? Give feedback.
-
For languages that supports interfaces (or abstract base classes) the "normal" way of writing bindings leaves another interface around e.g:
Will give the following in e.g Python:
So the question is what to do with it:. Should I leave it around or try to get rid of it. I tried this but gives error:
nativeOnly is being compiled without replacement, this will fail at runtime.
:So perhaps import both, but that seems redundant:
Maybe just erase it. This looks like a better way:
For interfaces that represents real objects in the bound runtime, then it looks good to use an import instead to erase it, since the type will then represented correctly when transpiled:
This will give the right type represented:
Is this the right way to think about it, or?
Beta Was this translation helpful? Give feedback.
All reactions