![](/img/trans.png)
[英]How could I check for a particular property at runtime, along with its return type?
[英]Eiffel: how do I get the type of a particular operand of a procedure
以下代码演示了如何检索有关例程对象的开放参数类型的信息:
p: ROUTINE -- Routine object.
t: TYPE [detachable ANY] -- Current open argument type.
do
p := agent (i: INTEGER; s: STRING)
do
end
across
1 |..| p.open_count as i
loop
t := p.generating_type.generic_parameter_type (1).generic_parameter_type (i.item)
io.put_string (t.name)
io.put_new_line
end
对我来说,上面的代码可以打印
INTEGER_32
!STRING_8
评论:
p.open_count
给出打开参数的总数。 p.generating_type
检索例程对象的类型。 p.generating_type.generic_parameter_type (1)
检索打开参数元组对象的类型。 generating_type
检索与指数开参数的类型i.item
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.