cancel
Showing results for 
Search instead for 
Did you mean: 

Influence of leading whitespace on code execution

xinyu_gai
New Contributor

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 
2 REPLIES 2

jay_han
New Contributor
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 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>> --> You received this message because you are subscribed to the Google Groups> "Kdb+ Personal Developers" group.> To unsubscribe from this group and stop receiving emails from it, send an> email to personal-kdbplus+unsubscribe@googlegroups.com.> To post to this group, send email to personal-kdbplus@googlegroups.com.> Visit this group at https://groups.google.com/group/personal-kdbplus.> For more options, visit https://groups.google.com/d/optout.

ikorkhov
New Contributor
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