rust-bips icon indicating copy to clipboard operation
rust-bips copied to clipboard

Dynamically selectable languages

Open nuttycom opened this issue 8 months ago • 0 comments

The recent choice to make language a statically-determined property makes it very awkward to allow users to choose a language at runtime. Consider the following code, which is required to allow such switching:

https://github.com/zcash/zcash/blob/master/src/rust/src/zip339_ffi.rs#L9-L184

It doesn't make sense to me that an application should statically commit to a single language. The language should be represented as an enum, and provided as a runtime argument to mnemonic generation. If a particular application wishes to support only a subset of languages, then there are a couple of possible approaches; one would be to, instead of representing the language as an enum, use a trait that expresses the equivalent F-algebra as a handler with default impls; this is effectively what the "handler" method is providing (though taking a set of closures, instead of a visitor trait having a method for handling each language case).

Overall, though, using an enum would be the simpler approach. At very least, the Language impl should be able to provided at runtime, not just statically, so that users who wish to write their own implementation of Language can cause a language to be selected based on runtime information.

nuttycom avatar May 20 '25 15:05 nuttycom