Re: Updates on Eu 4.2.0
- Posted by petelomax Jan 27, 2022
- 1680 views
ghaberek said...
using atom myFoo = newFoo() do saveFoo( myFoo ) end using -- tries to delete myFoo but a reference is held in globalFoos, so -- it throws an error ("cannot delete myFoo: too many references")
I think I'd prefer
atom myFoo = newFoo() saveFoo(myFoo) myFoo = cleanup(myFoo) -- tries to delete myFoo but a reference is held in globalFoos, so -- it throws an error ("cannot delete myFoo: too many references")
Then you could do things like (in Phix/if Euphoria gets try/catch)
try myFoo = cleanup(myFoo) -- (sets myFoo to NULL if all goes well) catch e ... end try
Of course you could make the myFoo = part optional/implicit, and/or invoke cleanup({myFoo,myOtherFoo,etc}), or maybe use delete(x,true) where the second parameter forces "last ref" checks