Skip to content

[Proposal] CEP 1: context managers and “with” statement #1

@shdown

Description

@shdown

“Хожу к себе с докладом,
Воззвания пишу…” — М.Щ.

fun RestoreScope(n) {
    f := nil
    fun f(dict) {
        Scale(dict.n)
    }
    return {"_enter_func": nil, "_exit_func": f, "n": n}
}

fun foo(a, b, s) {
    old_s := Scale()
    with (RestoreScope(old_s)) {
        Scale(s)
        return a / b
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions