Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
dcuny said...

Conceptually, finally could be implemented in Euphoria without try/catch, by extending the function/procedure block to include the clause:

I haven't read to the end of this thread yet, but conceptually, finally has been implemented in euphoria:

 
function cleanup_foo(sequence stuff) 
    close( stuff[1] ) 
    defrob( stuff[2] ) 
    return 0 
end function 
 
function foo() 
    integer fn = open(...) 
    sequence frob = frob:new() 
    sequence finally = delete_routine( {fn, frob}, routine_id("cleanup_foo") ) 
    --- ... do stuff.... 
    if blah then 
        return 0 -- cleanup_foo(finally) is called here 
    end if 
    --- .... more stuff... 
    return 1 -- cleanup_foo(finally) called here 
end function 
 

Of course, you could simply put the cleanup stuff directly on the resources (and #open()# can do this for you).

man:std_machine.html#_5773_delete_routine

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu