It could be that inside the error trap you aren’t referencing the actual table. Is “t” just the variable that represents the table inside a function?
q)tab
stock name
test ross
q)
q)
q)f1 `test
'length
[1] f1:{tab upsert x}
^
q))
q))meta tab
c | t f a
-----| -----
stock| s
name | s
q))
q))
q))tab.stock
,`test
q))
q)f2 tab
'length
[1] f2:{x upsert (“test”;“ross”)}
^
q))meta x
c | t f a
-----| -----
stock| s
name | s
q))
q))
q))x.stock
'x.stock
[3] x.stock
Using the function f1, I was able to access the columns using tab directly. However it seems that using tab as the input “x” I am unable to address the columns. As to why this is exactly I’m not 100%, but it appears that without using the table directly q is unable to locate the table to address the columns, in this way.
Within thesecond function, you could access the column using x`stock e.g.<o:p></o:p>
<o:p> </o:p>
q)tab:( stock:1#test;name:1#ross)<o:p></o:p>
q){x upsert (“test”;“ross”)}tab<o:p></o:p>
'length<o:p></o:p>
[1] {x upsert(“test”;“ross”)}<o:p></o:p>
^<o:p></o:p>
q))x.stock<o:p></o:p>
'x.stock<o:p></o:p>
[3] x.stock<o:p></o:p>
^<o:p></o:p>
q))x`stock<o:p></o:p>
,`test<o:p></o:p>
On Monday, January 15, 2018 at 10:26:07 AM UTC, Ross Edens wrote:
Hi,
It could be that inside the error trap you aren’t referencing the actual table. Is “t” just the variable that represents the table inside a function?
q)tab
stock name
test ross
q)
q)
q)f1 `test
'length
[1] f1:{tab upsert x}
^
q))
q))meta tab
c | t f a
-----| -----
stock| s
name | s
q))
q))
q))tab.stock
,`test
q))
q)f2 tab
'length
[1] f2:{x upsert (“test”;“ross”)}
^
q))meta x
c | t f a
-----| -----
stock| s
name | s
q))
q))
q))x.stock
'x.stock
[3] x.stock
Using the function f1, I was able to access the columns using tab directly. However it seems that using tab as the input “x” I am unable to address the columns. As to why this is exactly I’m not 100%, but it appears that without using the table directly q is unable to locate the table to address the columns, in this way.
I believe that as foo3 was called whilst still in break mode i.e. q)), it could access table t directly and run successfully. If you exit break mode and try, it should fail just like foo2. e.g.
q)foo3:{ t:(a:1,2;b:3,4); t.a}
q)foo3
't.a
[1] foo3:{ t:(a:1,2;b:3,4); t.a}
As for documentation the following links may be helpful, although a definitive answer as to why dot notation works in this way appears hard to come by: