dafny-lang / dafny

Dafny is a verification-aware programming language
https://dafny.org
Other
2.94k stars 263 forks source link

Extern V2 for Java and Rust - design #5784

Open robin-aws opened 2 months ago

robin-aws commented 2 months ago

The current approach for connecting Dafny code to code in other target languages is to add {:extern} to various program elements, and write additional target language shim code to connect what the Dafny code generators spit out to existing or freshly-written code.

There are a number of issues with this approach:

We're in the current state mostly because {:extern} grew organically as Dafny gained compilation at all, and then multiple compilation targets. We need to step back and design a better approach. This will likely result in a new set of attributes per target language to support accurately binding Dafny symbols/types to existing code features, such that Dafny code generation is always sound under the assumption these bindings are accurate.

To ensure we don't overfit the general approach to a particular language, we can focus on Java and Rust together at first, as two important and very different target languages.

To further bound the initial scope, the new approach should at least handle the simple and aggregate Smithy types supported by smithy-dafny.

Relevant issues for background: https://github.com/dafny-lang/dafny/issues?q=is%3Aopen+is%3Aissue+label%3A%22area%3A+ffi%22