The main source of the confusion is a presumably unintentional consequence
of a "really radical" change introduced a decade ago [0]. This feature
(all arguments are equal, but some arguments are more equal than others;
actually, it affects more than mere arguments) does not discriminate and it
is quite capable of biting an apprentice, a guru and anyone in between.
[0] [Jgeneral] explicit arguments
http://www.jsoftware.com/pipermail/general/2006-January/026354.html
On Fri, Nov 4, 2016 at 11:26 PM, Xiao-Yong Jin <[email protected]>
wrote:
> Is there any document about this behavior in the wiki or the online
> help? I had never encountered this issue, for I had never reused
> public names for private definitions, until I was bitten by this.
>
> Can someone put a simple explanation with examples in the dictionary?
> Such peculiar behavior of name resolution is important to document.
>
> > On Nov 4, 2016, at 8:40 AM, 'Pascal Jasmin' via Programming <
> [email protected]> wrote:
> >
> > 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
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm