its a peculiarity of explicit adverbs
g a
g (1 : 0)
g=.+:
u y
)
nothing was resolved in the binding. Though its still a bug imo.
Better practice is to write "semi-tacit" adverbs. Ones that do not access y,
and so return a tacit verb
a_t_ =: 1 : 'u'
g a_t_
]
This resolves to a verb. unnaffected with assignment
b_t_ =: 1 : ('g =. +:';'u')
g b_t_
]
----- Original Message -----
From: Xiao-Yong Jin <[email protected]>
To: [email protected]
Sent: Friday, November 4, 2016 11:26 PM
Subject: Re: [Jprogramming] stack error or private/public name collision
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