Much of this is alrady documented at http://code.kx.com/wiki/Reference/ColonColon
as an infix dyad, :: is
global assign if inside a function
assign if outside a function and a space before ::
create view if outside of a function and no space before ::.
e.g.
/view, note no space between target variable ‘a’ and ::
a::b+c
/assign, note space between target variable ‘a’ and ::
a ::b+c
/assign to global from within lambda
{a::b+c}
wrapping in () changes verb to noun. e.g. (+) as flip
q)(+)(1 2;3 4)
1 3
2 4
q)b:2;c:3;a(::)b+c / identity, not assign, hence error
'a
Missing arg and identity (op which returns its arg; a “no-op”) are not quite the same
q)(null;{-8!x}‘;type’)@:0N!1_value {[x;y]}[::;]
(::;::)
1 0
0x010000000a0000006500 0x010000000a00000065ff
101 101
even though the display and type id are the same, null and serialization reveal they are not.
q)(-8!)@/:1 _ value{x+y}[::;] / missing arg projects -8!
0x010000000a0000006500
![-8;]
q)1 2 3(::) / identity used as index, just return the lhs
1 2 3
q)(::)1 2 3 / identity monad, just return the rhs
1 2 3
q)eval(::;a;0) / dyadic, assign 0 q)eval(::;
a) / monadic, identity
0
identity can be useful in functional programming.