TulipaEnergy / TulipaIO.jl

Apache License 2.0
1 stars 4 forks source link

Try to refactor set_tbl_col_impl into a "wrapper" to convert Julia data to DDB #34

Closed abelsiqueira closed 3 weeks ago

abelsiqueira commented 6 months ago

The set_tbl_col_impl function runs

df = ...
register(...)
# STUFF
unregister(...)

The STUFF part could be different in other parts of the code. In that case, we can try to generalise the function (and give it a better name) to allow this.

With a do-block, we might be able to have a visually pleasant syntax. E.g.,

wrapper_stuff(...) do ...
   # STUFF
end

and then wrapper_stuff is implemented as

function wrapper_stuff(STUFF::Function, ...)
  ...
  try
    STUFF(...)
  finally
    ...
  end
end

PS. Consider name as_table.