Replies: 2 comments 7 replies
-
I don't understand the need for the feature you propose. Why don't you move the things you want to delete - but still tests against - to a folder called OLD, instead of deleting them? If you can't move the old stuff because you've already edited/deleted it, then you can recover it using git. |
Beta Was this translation helpful? Give feedback.
-
I think it's great that you prove that the new code is correct with respect to the old code.
That's true: if your remove something, you loose the guarantee. That's the same with code, if you remove code, you'll lose the functionality of this code. If you want to be backwards compatible with code, you have to create code and use explicit versioning instead of deleting the previous one. For verification methods and predicates, it's the same. So for example, if you anticipate you are going to evolve your types and predicates, you could keep all these even more precise predicates and types within versions in a sub-folder of your project, |
Beta Was this translation helpful? Give feedback.
-
Sometimes I want to refactor some code.
Compose/decompose or just move things around.
These kinds of changes can get rather complicated
and involve lots of small changes,
especially in Dafny with all the details I can put into specifications.
As I work the problem the scope of change can get mingled with what was previously correct.
To try and avoid this I will often write a lemma to prove that my two "ways" are equivalent.
However, the problem comes when I want to commit something.
The goal of the refactor is to not leave the old code around.
So while the lemma is useful to me,
and maybe it could exist in the PR for a time,
eventually it needs to be removed.
It needs to be removed because the code that it is based on is getting removed.
Once it is removed, if any additional changes happen,
how do I know that everything is still equivalent?
My idea was to have a way to include a file from a git SHA1.
Obviously this would need to be carefully done,
but it would let me commit a lemma that includes code from a previous version of a file in git history.
In fact, this verification could stick around after the refactor to ensure correctness.
I offer an example.
Say I have a predicate function that defines a type of Valid.
I want to move this predicate and expand on it slightly.
I also want to start using a Subset type based on this new predicate.
Rather than having
requires ValidBar
all over the place.Now for the magic.
I was thinking of something like this.
SHA1
is the git commit withFoo.dfy
that I want to verify against.So if I want to verify things in old versions of Foo or even delete Foo because I'm done with it,
this test will continue to act as a memory and keep me honest.
Beta Was this translation helpful? Give feedback.
All reactions