ada语言涉及程序的疑点
我是 Ada 的初学者,我遇到了如下所示的一段代码:
procedure Null_Proc is
begin
null;
end;
现在据我所知,Ada 中的过程不会返回任何内容。我的疑问是这个过程 Null_proc 是做什么的?我的意思是我不清楚程序的定义。
I am a beginner in Ada and I have come across a piece of code which is shown below:
procedure Null_Proc is
begin
null;
end;
Now as per my knowledge the procedure in Ada doesn't return anything. My doubt is what does this procedure Null_proc do? I mean I am not clear with the definition of the procedure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它什么也不做。
当必须调用过程但不必执行任何操作时,它可能很有用;否则,它就没有什么价值。 (我凭记忆工作;我假设 Ada 确实允许函数或过程作为其他函数的参数 - 就 C 而言,是指向函数的指针。)
It does nothing.
It might be useful when a procedure must be called but nothing must be done; otherwise, it has little value. (I am working from memory; I assume that Ada does allow functions or procedures as parameters to other functions - in terms of C, pointers to functions.)
当所有“真实代码”都在
with
ed 包中时,我就以这种方式编写主例程。如果您的程序使用任务分配,这种情况尤其可能发生,因为主例程无法像任务那样接受集合点,因此它通常最终无事可做。您的整个程序将保持活动状态,直到所有任务完成,因此主例程实际上不需要执行任何操作。另一种可能的用途是实现某种默认例程以提供回调。
I've been known to write main routines that way when all the "real code" was in the
with
ed packages. This is particularly likely if your program uses tasking, as the main routine cannot accept rendezvous like a task can, so it often ends up with nothing useful to do. Your entire program will stay active until all tasks complete, so the main routine really doesn't have to do anything.Another possible use would be for implementing some kind of default routine to supply to callbacks.