Why does in first following case protected execution work, but in second does not?:
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:
Hmm, I suspect something after trying:
q)@[{@[cols t; (cols t)?`c; :; `cc]}; `; `columnNotFound]
`columnNotFound
The protected execution is using the argument you're supplying. The first two examples are projections but the last is not, so it fails on execution.
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)
In your upd, making the @
apply a function is forcing the argument in the protected execution to be used.
q){@[cols t;(cols t)?`c;:;`cc]}`
'length
[1] {@[cols t;(cols t)?`c;:;`cc]}
^
q))