cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving values from a dictionary using namespacing

eohara_kdb
New Contributor III

Hi all,

 

I would like to understand the following behaviour:

If the dictionary values are all atoms of the same type, treating the dictionary as a namespace will throw an error when retrieving a value. Otherwise it seems to work ok.

 

q)dict:`FAWF`faw`erses`gdgr`gr!til 5
q)dict
FAWF | 0
faw  | 1
erses| 2
gdgr | 3
gr   | 4
q)dict.gr
'gr
  [0]  dict.gr
       ^
q)dict:`FAWF`faw`erses`gdgr`gr!(2;44i;54.7;`fs;"ff")
q)dict
FAWF | 2
faw  | 44i
erses| 54.7
gdgr | `fs
gr   | "ff"
q)dict.gr
"ff"
q)dict:`FAWF`faw`erses`gdgr`gr!enlist each til 5
q)dict
FAWF | 0
faw  | 1
erses| 2
gdgr | 3
gr   | 4
q)dict.gr
,4

 Thanks,

Eoghan

1 ACCEPTED SOLUTION

gyorokpeter-kx
Contributor
Contributor

Probably because this syntax is only intended to use with regular namespaces (whose names begin with a dot). When you create a namespace it always has a mixed list in its values because a  ` | :: item is implicitly inserted into it. So the lookup code might be written with the assumption that this always needs to be the case.

View solution in original post

1 REPLY 1

gyorokpeter-kx
Contributor
Contributor

Probably because this syntax is only intended to use with regular namespaces (whose names begin with a dot). When you create a namespace it always has a mixed list in its values because a  ` | :: item is implicitly inserted into it. So the lookup code might be written with the assumption that this always needs to be the case.