﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3767	Defer keyword	matwachich@…		"Why not a Defer keyword for the AutoIt language?
Just like [https://golangbot.com/defer/]

Code is much more clear and clean when Close/Terminate/Deinit/Destroy is just below the corresponding Open/Startup/Init/Create.
And lesser memory leaks (handle not closed...).

{{{
Func readFile($sFile)
    Local $hF = FileOpen($sFile)
    Defer FileClose($hF)

    Return FileRead($sFile)
EndFunc

Func doStuff()
    Local $hDC = _WinAPI_GetDC()
    Local $hFont = _WinAPI_CreateFont()
    Local $hOld = _WinAPI_SelectObject($hDC, $hFont)
    Defer
        _WinAPI_SelectObject($hDC, $hOld)
        _WinAPI_DestroyObject($hFont)
        _WinAPI_ReleaseDC($hDC)
    EndDefer

    ... do stuff, and don't care about ressources freeing ...
EndFunc

; OR

Func doStuff()
    Local $hDC = _WinAPI_GetDC()
    Defer _WinAPI_ReleaseDC($hDC)

    Local $hFont = _WinAPI_CreateFont()
    Defer _WinAPI_DestroyObject($hFont)

    Local $hOld = _WinAPI_SelectObject($hDC, $hFont)
    Defer _WinAPI_SelectObject($hDC, $hOld)

    ... do stuff, and don't care about ressources freeing ...
EndFunc
}}}
"	Feature Request	new		AutoIt		None		defer keyword	
