Skip to content

Prevent calling collect multiple times #338

@giann

Description

@giann

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    vmIssue related to the VM

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions