to pass by value/workaround, g f. a 5 5
________________________________ From: Henry Rich <[email protected]> To: [email protected] Sent: Friday, November 4, 2016 7:40 AM Subject: Re: [Jprogramming] stack error or private/public name collision Consider: g =: ] a=:1 :0 g=.+: u y ) g 5 5 g a 5 10 inside a, u is defined as g, because verbs are passed by name. There is an exception: u v m n x y are always replaced by their values when they are taken from the execution queue. Henry Rich On 11/4/2016 5:51 AM, 'Jon Hough' via Programming wrote: > I'm not sure what the rule is, but if you do: > > g =: ] > a =: 1 : 0 > h =. u > g =. +: > h y > ) > > g a 1 > > NB. what is g? > g > it shows g as ], > i.e Global g doesn't get reassigned. > > Also, > g =: ] > a =: 1 : 0 > g =. u > g y > ) > > ^ a 1 > > NB. what is g? > g > > shows ], > so global g doesn't get reassigned here either. But the g in the line "g y" > is ^ , i.e. a ignores the locally defined g. > > Sorry that's not helpful. The dictionary entry for explicit definitions [1], > doesn't seem to have much to say about it. > > Interestingly, if you erase g inside the conjunction ([2]), and then assign > local g, you will still get a stack error: > > g =: ] > a =: 1 : 0 > (4!:55) <'g' > g =. u > g y > > ) > > g a 1 > > > > > [1] http://www.jsoftware.com/help/dictionary/d310n.htm > [2] http://www.jsoftware.com/help/dictionary/dx004.htm > -------------------------------------------- > On Fri, 11/4/16, Xiao-Yong Jin <[email protected]> wrote: > > Subject: [Jprogramming] stack error or private/public name collision > To: [email protected] > Date: Friday, November 4, 2016, 1:52 PM > > Is the following a bug? > > g=:] > a=:1 :0 > g=.u > g y > ) > g a 1 > |stack error: g > | g y > a=:1 :0 > f=.u > f y > ) > g a 1 > 1 > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
