Kdb 保护性处决,2起
为什么在以下第一种情况下,受保护的执行起作用,而在第二种情况下则不起作用Kdb 保护性处决,2起,kdb,k,Kdb,K,为什么在以下第一种情况下,受保护的执行起作用,而在第二种情况下则不起作用 q)t:([]a:1 2;b:3 4); q)@[@[cols t; ; :; `bb]; (cols t)?`b; `columnNotFound] `a`bb q)@[@[cols t; ; :; `cc]; (cols t)?`c; `columnNotFound] // 1. works perfectly `columnNotFound q)@[@[cols t; (cols t)?`c; :; `cc]; `;
q)t:([]a:1 2;b:3 4);
q)@[@[cols t; ; :; `bb]; (cols t)?`b; `columnNotFound]
`a`bb
q)@[@[cols t; ; :; `cc]; (cols t)?`c; `columnNotFound] // 1. works perfectly
`columnNotFound
q)@[@[cols t; (cols t)?`c; :; `cc]; `; `columnNotFound] // 2. exception does not handled
'length
[0] @[@[cols t; (cols t)?`c; :; `cc]; `; `columnNotFound]
^
Upd:
嗯,我试了一下后怀疑:
q)@[{@[cols t; (cols t)?`c; :; `cc]}; `; `columnNotFound]
`columnNotFound
受保护的执行正在使用您提供的参数。前两个示例是投影,但最后一个不是,因此它在执行时失败
q){@[cols t;x;:;`bb]}(cols t)?`b
`a`bb
q){@[cols t;x;:;`cc]}(cols t)?`c / thrown into error trap
'length
[1] {@[cols t;x;:;`cc]}
^
q))\
q)@[cols t;(cols t)?`c;:;`cc] / fails on execution
'length
[0] @[cols t;(cols t)?`c;:;`cc]
^
q)
在upd中,使@
应用函数就是强制使用受保护执行中的参数
q){@[cols t;(cols t)?`c;:;`cc]}`
'length
[1] {@[cols t;(cols t)?`c;:;`cc]}
^
q))
受保护的执行正在使用您提供的参数。前两个示例是投影,但最后一个不是,因此它在执行时失败
q){@[cols t;x;:;`bb]}(cols t)?`b
`a`bb
q){@[cols t;x;:;`cc]}(cols t)?`c / thrown into error trap
'length
[1] {@[cols t;x;:;`cc]}
^
q))\
q)@[cols t;(cols t)?`c;:;`cc] / fails on execution
'length
[0] @[cols t;(cols t)?`c;:;`cc]
^
q)
在upd中,使@
应用函数就是强制使用受保护执行中的参数
q){@[cols t;(cols t)?`c;:;`cc]}`
'length
[1] {@[cols t;(cols t)?`c;:;`cc]}
^
q))