Scope issue with begin/end


I thought that

module MyPkg
    const b = begin
        a = 2
        b = a

MyPkg.b # return 2 as wantedd
MyPkg.a # return 2, but I wanted it not to exist. 

would give me a variable b with the value 2 but no variable a. But after executing this code, the binding for a exists. Is there a way i can do “precomputations” to construct an object without having them saved in the environment ? The goal is to have a package do precomputations but i do not want the package’s namespace to be polluted.

begin does not create a scope — you want to use let for that.


Thanks this is exactly what i wanted :slight_smile: