是否有Ada等效的离开功能未实现?

时间:2017-11-27 19:49:39

标签: ada notimplementedexception

在.Net中,在开发过程中逐渐实现接口是常见的做法,因此并非所有接口函数都是在前几轮开发中实现的。这样的例子在C#中看起来像这样:

class ClassA{
    MyPropertyPub:number;
    private _myPropertyPriv
}
**later
var obj:ClassA = { MyPropertyPub:3 };

但是,我还没想出如何在Ada中做同等效果。我想开发出一个包装规格的主体,同时在一些功能上打开门。有没有办法立即抛出异常?现在,我有以下内容,它给了我一个编译器错误public string FutureGetString() { // Not developed yet. throw new NotImplementedException(); }

missing "return" statement in function body

2 个答案:

答案 0 :(得分:5)

我见过这个(由AdaCore高级工程师推荐):

function NotImplemented ( Input : Integer ) return Boolean is
begin
   raise Program_Error;
   return NotImplemented (Input);
end;

我想知道编译器是否会警告无限递归,但是没有。

答案 1 :(得分:4)

function Not_Implemented (Input : in Integer) return Boolean is
   pragma Unreferenced (Input);
begin
   pragma Compile_Time_Warning (True, "Not_Implemented has not been implemented yet.");
   return raise Program_Error with "Not_Implemented has not been implemented yet.";
end Not_Implemented;