Is there something special about reference counting when it comes to scalar local variables inside a function?
It looks like local scalars can share storage of their values with one extra reference (for bookkeeping?)
Local scalar reference counting seems quite different from the local vector counterpart.
: air:perf ; q
KDB+ 3.0 2012.12.04 Copyright (C) 1993-2012 Kx Systems
m32/ 2()core 4096MB hjh air.local 10.0.1.2 PLAY 2013.03.04
q)a:0
q)b:0
q)c:d:0
q)-16!a
1i
q)-16!b
1i
q)-16!c
2i
q)-16!d
2i
q)f:{la:0; lb:0; lc:ld:0; 0N!-16!la; 0N!-16!lb; 0N!-16!lc; 0N!-16!ld;}
q)f // la lb lc ld seem to “share” 0 and one extra reference
5i
5i
5i
5i
q)f:{la:0; lb:0; lc:ld:1; 0N!-16!la; 0N!-16!lb; 0N!-16!lc; 0N!-16!ld;}
q)f
3i
3i
3i
3i
q)f:{la:0; lb:-1; lc:ld:1; 0N!-16!la; 0N!-16!lb; 0N!-16!lc; 0N!-16!ld;}
q)f
2i
2i
3i
3i
q)f:{la:til 1; lb:til 1; lc:ld:til 3; 0N!-16!la; 0N!-16!lb; 0N!-16!lc; 0N!-16!ld;}
q)f // local vectors la and lb don’t seem to share
1i
1i
2i
2i
q)