[英]eiffel type conformance and attachement check not working
Trying to solve one of the SCOOP consequences with make_from_separate
I'm running into an issue where at runtime types seem to be the same and won't pass the attached
statement.尝试使用
make_from_separate
解决 SCOOP 后果之一我遇到了一个问题,即在运行时类型似乎相同并且不会通过attached
的语句。
non_separate_from_any, any_from_separate (v: separate ANY): ANY
local
l_array: ARRAY[detachable ANY]
l_res_ll_arr_det_any: LINKED_LIST[ARRAY[detachable ANY]]
l_arr_det_str: ARRAY[detachable STRING]
do
if
attached {REAL} v as l_v
then
Result := l_v
elseif attached {separate INTEGER_32_REF} v as l_v then
Result := l_v.as_integer_32
elseif attached {INTEGER} v as l_v then
Result := l_v
elseif attached {separate STRING} v as l_v then
create {STRING} Result.make_from_separate (l_v)
elseif attached {separate STRING_32} v as l_v then
create {STRING_32} Result.make_from_separate (l_v)
elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
create l_res_ll_arr_det_any.make
across
l_v is l_list_item_sep
loop
create l_array.make_empty
separate l_list_item_sep as l_list_item_sep_tmp do
across
l_list_item_sep_tmp as l_array_item_non_sep
loop
if attached l_array_item_non_sep as l_any_sep then
l_array.put (non_separate_from_any (l_any_sep), l_array_item_non_sep.cursor_index)
else
l_array.put (Void, l_array_item_non_sep.cursor_index)
end
end
end
l_res_ll_arr_det_any.extend (l_array)
end
Result := l_res_ll_arr_det_any
elseif attached {separate ARRAY[detachable STRING]} v as l_v then
create l_arr_det_str.make_empty
across
l_v as l_s_sep
loop
if attached l_s_sep.item as l_s_sep_att then
l_arr_det_str.put (create {STRING}.make_from_separate (l_s_sep_att), l_s_sep.cursor_index)
else
l_arr_det_str.put (Void, l_s_sep.cursor_index)
end
end
Result := l_arr_det_str
else
check
implement_me: False
then
do_nothing
end
end
ensure
instance_free: Class
end
Declarations are following:声明如下:
DB_TUPLE_COL_NAMES -> items: ARRAY[STRING]
DEFAULT_DB_ACTION -> column_names: separate like {DB_TUPLE_COL_NAMES}.items
DEFAULT_DB_ACTION -> make_from_separate (other: separate like Current)
At runtime I got a other.column_names -> at runtime: ARRAY[detachable STRING]
在运行时我得到了
other.column_names -> at runtime: ARRAY[detachable STRING]
How can that be!!!这个怎么可能!!! thats the reason of my implementation of
any_from_separate
with l_arr_det_str
这就是我使用
l_arr_det_str
实现any_from_separate
的原因
It looks like the actual type of the object is ARRAY [detachable STRING]
rather than ARRAY [STRING]
.看起来 object 的实际类型是
ARRAY [detachable STRING]
而不是ARRAY [STRING]
。
Change改变
elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
create ll_arr_det_any.make -- l_arr_det_str: ARRAY[detachable STRING]
with和
elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
create l_arr_str.make -- l_arr_det_str: ARRAY[STRING]
My Error was into {SCOOP_UTIL}.any_from_separate
.我的错误是
{SCOOP_UTIL}.any_from_separate
。
As作为
{separate LINKED_LIST[separate ARRAY[ANY]]}
conforms to符合
{separate LINKED_LIST[separate ARRAY[detachable ANY]]}
it was taking this path and I interpreted that I had to create an它正在走这条路,我解释说我必须创建一个
ARRAY[detachable ANY]
but was a ARRAY[ANY]
. ARRAY[detachable ANY]
但它是一个ARRAY[ANY]
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.