Dan Bron wrote: >> NB. Looks like there is a bug in ". > > This isn't a bug in ". (nor is it a bug in ~ as I once surmised [1]). > > The behavior is explained in the "stacking by name" thread [2]. The > special local names x y u v m n are stacked by value. > > That is, when one of these names is encountered in a local context, its > value is evoked immediately. This causes a problem when the name in > question doesn't have a value. The result is a value error, as in your > example. > > Here's a simpler demonstration, which doesn't make use of ". (or ~ etc): > > foo_V =: 3 : 0 > dummy =. V/ NB. Note capital V is not a special name > 3 NB. Return constant 3 > ) > foo_v =: 3 : 0 > dummy =. v/ NB. Note lowercase v *is* a special name > 3 NB. Return constant 3 > ) > > foo_V '' > 3 > foo_v '' > |value error: v > | dummy=. v/ > > This behavior (stacking special names by value) is practical and you've > enjoyed the benefit of it many times, without knowing it. The suggestion > has been made to extend the behavior to all local names, rather than > limiting it to the special names [3]. > > -Dan > > [1] http://www.jsoftware.com/jwiki/System/Interpreter/Bugs#evokelocalnames > and more discussion at > http://www.jsoftware.com/jwiki/DanBron/Temp/IsEvokeBroken > > [2] http://www.jsoftware.com/pipermail/programming/2009-August/015914.html > > [3] http://www.jsoftware.com/pipermail/beta/2006-April/000840.html and at > [1] too. > >
I found these pages helpful as well as the excellent references above: http://www.jsoftware.com/help/jforc/parsing_and_execution_ii.htm http://www.jsoftware.com/help/jforc/writing_your_own_modifiers.htm -- David Mitchell ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
