Would it make sense to roll back module definitions which error half-way?

Consider this:

julia> module M
         const a = 1
         error("e")
         const b = 2
       end
ERROR: e
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] top-level scope
   @ REPL[1]:3

julia> M.a
1

So M and M.a are defined, even though defining the module failed half-way. Is that not a bit ugly? I’m reminded of database transaction terminology, where one of the desirable and mandatory properties for a transaction in databases is atomicity:

The “all or nothing” property. A transaction is an indivisible unit that is either performed in its entirety or is not performed at all.

3 Likes