Parsing nit

Consider the query “select from t where date within dr” where dr isdefined in this workspace. its functional form is “?[t;enlist(within;adate;dr);0b;()]". I just noticed that parse gives "dr” andnot “dr” and that indeed “?[t;enlist(within;adate;dr);0b;()]” works,too. I am a baffled by this because when you pass a value you do it,well, by value, e.g., “dr2:dr” and not "dr2:dr"; so why is the drform of the query working as expected??

X-Mailer: iPhone Mail (7C144)Subject: Re: [personal kdb+] Parsing nitDate: Sat, 19 Sep 2009 20:36:59 +0100Cc: Kdb+ Personal Developers Because that is a parse treeLook it up in q for mortals (or arthur’s docs) AttilaOn 19 Sep 2009, at 13:41, annakh7 wrote:>> Consider the query “select from t where date within dr” where dr is> defined in this workspace. its functional form is “?[t;enlist> (within;adate;dr);0b;()]". I just noticed that parse gives "dr” and> not “dr” and that indeed “?[t;enlist(within;adate;dr);0b;()]” works,> too. I am a baffled by this because when you pass a value you do it,> well, by value, e.g., “dr2:dr” and not "dr2:dr"; so why is the dr> form of the query working as expected??>> >

Q for Mortals says: “A discussion of q parse trees is beyond the scopeof this tutorial.” Which Arthur docs do you have in mind exactly? TheAbridged Q Language Manual has scarcely anything at all to say on thistopic either.

On Sep 19, 7:41?pm, annakh7 <anna…> wrote:> … I just noticed that parse gives "dr" and&gt; not "dr" and that indeed "?[t;enlist(within;adate;dr);0b;()]" works,&gt; too.I think it's because the parser represents the identifier "dr" withthesymbol dr.q)parse "within[date;dr]"withindatedrq)type each parse "within[date;dr]"102 -11 -11hq)</anna…>

X-Mailer: Apple Mail (2.936)On Sep 19, 2009, at 8:41 PM, annakh7 wrote:> Consider the query “select from t where date within dr” where dr is> defined in this workspace. its functional form is “?[t;enlist> (within;`adate;dr);0b;()]”. I just noticed that parse gives “`dr” and> not “dr” and that indeed “?[t;enlist(within;`adate;`dr);0b;()]” works,> too. I am a baffled by this because when you pass a value you do it,> well, by value, e.g., “dr2:dr” and not “dr2:`dr”; so why is the `dr> form of the query working as expected??the workspace system is represented internally as a dictionary tree with symbol keys and arbitrary values. every global variable is retrievable by its name, and that’s how the parser resolves them.air:~ :) % qKDB+ 2.6 2009.09.15 Copyright (C) 1993-2009 Kx Systemsm32/ 2()core 2048MBq)dr:2009.01.01 2009.09.20q)get`dr2009.01.01 2009.09.20in the functional form you provided, as i understand it, dr is being interpreted by the command-line parser, so the argument list the implementation of ? sees is(t;enlist(within;`adate;2009.01.01 2009.09.20);0b;())one way to see the difference is to consider querying a remote service using a parsed query instead of a string:q)t:(date:2#.z.D)q)\p 5001and in another terminal:air:~ :) % qKDB+ 2.6 2009.09.15 Copyright (C) 1993-2009 Kx Systemsm32/ 2()core 2048MBq)h:hopen 5001q)h(?;`t;enlist(within;`date;dr);0b;())'drq)h(?;`t;enlist(within;`date;`dr);0b;())date----------2009.09.202009.09.20now it’s clear where the dereference takes place