On 07/06/2015 17:23, Marvin Humphrey wrote:
Rust is fascinating.  I wish I had time to learn it in depth right
now.  Since I don't know it cold, I can only offer abstract feedback.

I'm only starting to learn Rust and I don't have the intention to pursue the implementation of Rust bindings, at least for now. I mainly found it a nice exercise in learning the language.

Here's a refined version with some additional comments:

    https://gist.github.com/nwellnhof/299dd7315b8b54ac4e3d

For Go, we haven't quite
nailed it yet because the subtyping model, once it supports
overriding, will produce non-idiomatic behavior that Go programmers
will find surprising.

What do you mean exactly?

To what extent will this Rust proof-of-concept yield idiomatic Rust
APIs, with regards to the following concerns?

I don't know enough about Rust to really judge what is idiomatic. But our single inheritance model will never map cleanly to language like Rust. A Clownfish project will use a class hierarchy with virtual method dispatch and downcasting for many problems that a Rust programmer would solve with enumerated (algebraic) types and pattern matching.

*   naming conventions

This shouldn't be hard. I added some uppercase names to avoid name clashes which the Rust compiler even warns about.

*   method signatures

I think it's best to pass object arguments as trait objects because Rust can implicitly a cast a struct to every trait it implements. This should mostly remove the need for manual upcasting. As an optimization, final classes could be passed directly as structs.

*   object lifetimes

This shouldn't be a problem because the Clownfish bindings don't store any references internally.

*   use of host types, such as host strings not Clownfish strings

Shouldn't be a problem. With Rust, we can probably wrap string arguments without copying like we do in the Perl bindings.

*   package layout and distribution

For Rust, I'm not sure whether it's better to use parcel/final-class-name or the full class name for namespaces.

> *   subtyping behavior

If you mean to subtype Clownfish classes from the host language, I think this is a feature that we should consider to drop.

Nick

Reply via email to