-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Idea) Implement built-in Dafny types in Dafny source code #1775
Comments
"If this was implemented once in a Dafny prelude instead using classes and traits, and references to seq rewritten in the compiler" How come it needs to be defined both in a prelude, and rewritten in the compiler? Are you suggesting to implement Seq in Dafny using arrays and then not having a runtime specific part for it? If so, then what would you need to rewrite in the compiler? |
I think Robin is suggesting to have a class It would be nice to be able to just define |
I just expect this would need at least some compiler rewriting, since you can't just declare |
Wouldn't the compiler rewrite be to have an implicit |
I should not have used the term "prelude" in this case, as I'm not proposing Dafny source code that is directly Sequences are currently implemented in each runtime via one or more target language classes or similar datatypes, such as |
This is another improvement for the implementation of sequences that would be much nicer to do once in Dafny rather than N times in each runtime: #2859 |
…untime (#3167) Addresses #2390 for Go, via the strategy described in #1775. ~The only outstanding TODO I'm concerned with is the special-casing in the Go compiler needed to allow `Sequence<T>` to specify a custom equality predicate. I'm open to suggestions on how to improve that: at a minimum it should be checking the full type names, so that we can safely use the fact that the top-level `dafny` module is reserved, but I'm hoping there's a cleaner solution.~ Adds an internal `--bootstrapping` option only for use when compiling Dafny source used in the Dafny implementation itself. Also adds a `--platform` option to `package.py`: while debugging earlier attempts to change the build process, I realized that packaging for Mac OS was often picking the wrong platform. <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
Take
seq<T>
for example. The implementation in the C# and Java runtimes are very similar, and do not simply wrap an existing type in the target language runtime because the lazy evaluation of concatenation is very important for reasonable performance. If this was implemented once in a Dafny prelude instead using classes and traits, and references toseq<T>
rewritten in the compiler, we would get several benefits:This also may apply to some of the types tracked by the
Builtins
class, such as tuples (which can be thought of as built-in anonymousdatatype
s).Related: #1259
The text was updated successfully, but these errors were encountered: