[英]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.