Ada 程式設計/方面/無返回值
外觀
with No_Return
指定 No_Return 方面表示過程不能正常返回;它可能會引發異常,迴圈永遠執行,或終止程式。
非返回過程不能包含任何返回語句。如果非返回過程隱式返回(透過到達其語句序列的末尾),則Program_Error將在呼叫點引發。
在呼叫點,這可以檢測死程式碼並抑制關於缺少返回語句或缺少對變數賦值的警告。
procedureP ( … )withNo_Return;procedureQ (x :out… )isbeginifCondthenP ( … ); Some_Thing_Else; -- This is dead code--and due to No_Return probably a compiler warning!elsex := … ;endif; -- No warning about a missing assignment to x hereendQ;
No_Return 方面是在 Ada 2012 中引入的。它是[1]對 Ada 2005 中引入的 No_Return [Annotated] [Annotated] 的替代。[Annotated]
