Influence of leading whitespace on code execution


Hi there,


Please find the code below. I tested this in a local q instance for many times. Why are the last two values different?



q) a::b+1

q)c::b+1

q)a

3

q)c

3

q)b:5

q)a

3

q)c

6


Any advice is greatly appreciated!

Thanks,


Xinyu

run views or \b then you will see c but not a – q thinks c is aview but not a.On Tue, Aug 23, 2016 at 11:21 AM, Xinyu Gai <xinyu.gai> wrote:>> Hi there,>> Please find the code below. I tested this in a local q instance for many> times. Why are the last two values different?>>> q) a::b+1> q)c::b+1>> q)a> 3> q)c> 3>> q)b:5>> q)a> 3> q)c> 6>>> Any advice is greatly appreciated!>> Thanks,>> Xinyu>> –>

Submitted via Google Groups</xinyu.gai>

This behaviour is documented: http://code.kx.com/wiki/Reference/view

a view must have no side-effects, be set outside of a function, and be the only expression on the line, with no trailing semicolon, nor any preceding whitespace

On Tuesday, 23 August 2016 19:48:50 UTC+1, Xinyu Gai wrote:


Hi there,


Please find the code below. I tested this in a local q instance for many times. Why are the last two values different?



q) a::b+1

q)c::b+1

q)a

3

q)c

3

q)b:5

q)a

3

q)c

6


Any advice is greatly appreciated!

Thanks,


Xinyu