0

In the q 3.6 32bit I see something that I can not explain. Having the same parse trees these two expressions for y1 and for y2 give way too different results:

q)x:3
q)parse"y :: x*10"
::
`y
(*;`x;10)
q)parse"y:: x*10"
::
`y
(*;`x;10)
q)y1 :: x*10
q)y2:: x*10
q)x:5
q)y1
30
q)y2
50

Why the space is so meaningful here?

egor7
  • 4,678
  • 7
  • 31
  • 55
  • Adams answer answers your question - as an additional FYI, "views are not parsable" so your parse comparison isn't really valid. See https://code.kx.com/q/learn/views/#parse – terrylynch Dec 07 '20 at 10:42

1 Answers1

2

I believe defining a view in kdb has the condition that there should be no whitespace between the variable and ::

So in your example, y2 is a view and y1 is not, hence when you redefine x, the value of y2 is updated when referenced and y1 is not

Adam Bonham
  • 615
  • 4
  • 7