You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Defer function refers to take some operation on the exit of the section or the function, which is very convinient for case with resouce need to be released afterwards.
For example in the function with the multiple exit like.
function connect(...)
f = open(file)
if condition
close(f)
return ...
else
close(f)
return xxx
if the defer feature is added, the code could be simplied as
function connect(...)
f = open(file)
@defer close(f)
if condition
return ...
else
return xxx
I suggest to implement @defer as
macro defer(f(x...))
ccall(:jt_func_defer, f, x...)
end
where :jt_func_defer is some julia C-interface which invokes the expression f(x...) at the exit of function.
The text was updated successfully, but these errors were encountered:
The
Defer
function refers to take some operation on the exit of the section or the function, which is very convinient for case with resouce need to be released afterwards.For example in the function with the multiple exit like.
if the defer feature is added, the code could be simplied as
I suggest to implement
@defer
aswhere
:jt_func_defer
is some julia C-interface which invokes the expression f(x...) at the exit of function.The text was updated successfully, but these errors were encountered: