Suppose you created an instance of a class Window. The window is displayed to the user. Then an exception is thrown and the reference to the instance is lost, but the window is still visible to the user because the instance still exists (it is no longer mentioned).
Window
What to do in these circumstances?
I specifically talk about the Squirrel scripting language (http://www.squirrel-lang.org/). Unlike Java, it has no blocks finallyor finalizer methods, so exception handling doesn't work in this language?
finally
, finally Java:
Exception error = null; try { // do something } catch (Exception e) { error = e; } // My finally code goes here // ... if (error != null) { // Oh dear clean up all my resources - files, windows, sockets etc. throw error; }
, catch , , , - . , , (, , , try/catch), .
(, , , , ..), , , Java . close(). , , , () , . , GC, .
Source: https://habr.com/ru/post/1768385/More articles:ΠΊΠ°ΠΊ ΡΠΊΡΡΡΡ ΠΈ ΠΏΠΎΠΊΠ°Π·Π°ΡΡ Π² html-ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ΅ Π΄ΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈ - htmlΠ€ΡΠ½ΠΊΡΠΈΡ Eval Π² Π‘# - c#ΠΠ°Π³ΡΡΠ·ΠΊΠ° Π²Π΅Π±-ΡΡΡΠ°Π½ΠΈΡΡ Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ urllib2 ΠΏΡΠΈΠ²ΠΎΠ΄ΠΈΡ ΠΊ ΠΈΡΠΊΠ°ΠΆΠ΅Π½ΠΈΡ Π½Π΅ΠΆΠ΅Π»Π°ΡΠ΅Π»ΡΠ½ΠΎΠΉ ΠΏΠΎΡΡΡ? (ΡΠΎΠ»ΡΠΊΠΎ ΠΈΠ½ΠΎΠ³Π΄Π°) - pythoncreate a file and save it using memystream - c #How to add a checkbox control at the beginning of each row in a datagrid control? - c #Creating instances of classes that populate forms in Visual Studio - c #ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΈ ΠΎΡΠΈΡΡΠΊΠ° Π΄Π°Π½Π½ΡΡ Oracle - oraclePixel color search - c ++Stop executing php script - php#define file type - c ++All Articles