ada - 如何访问具有该过程作为访问参数的过程/函数的 Pre/Post 合同中的过程参数?
问题描述
Containers.Vector包定义了一些可以作为参数访问过程的过程。此过程支持一个参数。
例子:
procedure Update_Element
(Container : in out Vector;
Index : in Index_Type;
Process : not null access procedure (E : in out Element_Type));
procedure Query_Element
(Container : in Vector;
Index : in Index_Type;
Process : not null access procedure (E : in Element_Type));
是否可以在程序的E
前后合同中使用?Query_Element
Update_Element
写类似:
procedure Update_Element
(Container : in out Vector;
Index : in Index_Type;
Process : not null access procedure (E : in out Element_Type))
with Post => Element(Container,Index) = E;
导致编译错误:"E" is undefined
如果可能,该解决方案应该与 Spark 兼容。
解决方案
据我所知,当前的 Ada (2012) 标准不允许对子程序指针进行合约。它将在下一个 Ada 标准版本(目前称为 202x)中被允许。有关它的更多信息,例如:
推荐阅读
- c++ - 使用链表和类模板实现堆栈
- python - 使用套接字和线程,我的客户不会保持连接
- javascript - 使用 Chart.js 的折线图
- python - 打开一个“PNG”文件,然后是 numpy,然后是 base64,但没有显示图像?
- python - GradientTape.gradient 的概念理解
- ansible - 由于运行时错误,Ansible 失败模块无法工作
- mysql - 对动态获取的 ORDER BY 中的列进行索引
- c++ - C++ 需要所有声明的类型说明符
- prometheus - 使用二元运算符过滤 prometheus 查询结果
- java - 在 IntelliJ 中完成关键字时如何禁用自动插入空格?