buzz
buzz copied to clipboard
Prevent calling `collect` multiple times
Most of the time collect will clear external resources and should not be called more than once.
Currently, we avoid this with flag:
object File {
collected: bool = false,
// ...
mut fun collect() > void {
if (!this.collected) {
this.file.close();
this.collected = true;
}
}
// ...
}
But this is not ideal, namely because nothing prevents collected to be modified by the user.
Buzz should itself enforce the fact that that special method is called once.