Hello,this works out side of function --q)table: ( a: a
bc; n: (1 2 3))q)update b:
val from table
tableq)tablea n b-------a 1 valb 2 valc 3 valWhy does this not work..(is this something to do with variable scope? If so is there anydocumentation which explains variable scope?)In version 2.5 - it does not return type error but does not do updatein placeq)myf:{table: ([] a:
ab
c; n: (1 2 3)); update b:val from
table ; :table}q)myfa n—a 1b 2c 3In version 2.6q)myf:{table: ( a: a
bc; n: (1 2 3)); update b:
val from`table ; :table}q)myfq)'2010.02.05T11:41:35.519 typeThanks,RT
Hello,In your example table is a local variable.If you change to a global this will work.q)myf:{table::( a: a
bc; n: (1 2 3)); update b:
val fromtable;:table}q)tableq)myf[]a n b-------a 1 valb 2 valc 3 valq)tablea n b-------a 1 valb 2 valc 3 valRegards,Fintan.On Feb 5, 12:52?pm, Ramdas <rtha...> wrote:> Hello,>> this works out side of function -->> q)table: ([] a:
ab
c; n: (1 2 3))> q)update b:val from
table> table> q)table> a n b> -------> a 1 val> b 2 val> c 3 val>> Why does this not work..> (is this something to do with variable scope? ?If so is there any> documentation which explains variable scope?)>> In version 2.5 - it does not return
type error but does not do update> in place>> q)myf:{table: ( a: a
bc; n: (1 2 3)); update b:
val from> table ; ? ?:table}> q)myf[]> a n> ---> a 1> b 2> c 3>> In version 2.6>> q)myf:{table: ([] a:
ab
c; n: (1 2 3)); ? update b:val from>
table ; ? ?:table}> q)myf> q)'2010.02.05T11:41:35.519 type>> Thanks,> RT</rtha…>
Fintan,I understand that it works on global variables but what do I do if Ido not want to create a global variable?What happens when there are multiple users who connect to remote qprocess and create same global variable name?Thanks,RamdasOn Feb 5, 1:06?pm, fintanq <fint…> wrote:> Hello,>> In your example table is a local variable.>> If you change to a global this will work.>> q)myf:{table::( a: a
bc; n: (1 2 3)); update b:
val from> table;:table}> q)table> q)myf[]> a n b> -------> a 1 val> b 2 val> c 3 val> q)table> a n b> -------> a 1 val> b 2 val> c 3 val>> Regards,>> Fintan.>> On Feb 5, 12:52?pm, Ramdas <rtha...> wrote:>>>> > Hello,>> > this works out side of function -->> > q)table: ([] a:
ab
c; n: (1 2 3))> > q)update b:val from
table> > table> > q)table> > a n b> > -------> > a 1 val> > b 2 val> > c 3 val>> > Why does this not work..> > (is this something to do with variable scope? ?If so is there any> > documentation which explains variable scope?)>> > In version 2.5 - it does not return
type error but does not do update> > in place>> > q)myf:{table: ( a: a
bc; n: (1 2 3)); update b:
val from> > table ; ? ?:table}> > q)myf[]> > a n> > ---> > a 1> > b 2> > c 3>> > In version 2.6>> > q)myf:{table: ([] a:
ab
c; n: (1 2 3)); ? update b:val from> >
table ; ? ?:table}> > q)myf> > q)'2010.02.05T11:41:35.519 type>> > Thanks,> > RT- Hide quoted text ->> - Show quoted text -</rtha…></fint…>
charset=us-ascii;
format=flowed;
delsp=yes
Mime-Version: 1.0 (iPhone Mail 7D11)
Date: Fri, 5 Feb 2010 14:31:56 -0500
Cc: Kdb+ Personal Developers
Ramdas,
You could define the table in a different namespace. Eg: .ns1
Regards,
Nathan
Hi Ramdas,
Is there any particular reason that you want to use update in place??
The typical reason that update in place is nice is to save on memory reallocation. Otherwise, you can always assign the result of the update back to a new variable. If the “new” variable has the same name as the old, then memory allocation is not a problem.?
==Outside function scope==
q)table: ( a: a
bc; n: (1 2 3)) q)update b:
val from `table
q)table
q)table:update b:`val from table
==Which works inside function scope==
a
b`c; n: (1 2 3));table:update b:x from table;:table}process and create same global variable name?
Andrew?
Regarding “per user namespace” problems, this can be one way of doing
a crude separation of users sharing a Q process:
.z.pg:{
0N!"User, get: ",string .z.u;
system “d .usr.”,string .z.u;
x y} .z.pg
.z.ps:{
0N!"User, set: ",string .z.u;
system “d .usr.”,string .z.u;
x y} .z.ps
.z.pc:{
0N!“User, close: “,string .z.u;
delete from `$”.usr.”,string .z.u}
This still don’t have an answer.
Is this by design?