On Sat, Nov 5, 2016 at 12:06 AM, 'Pascal Jasmin' via Programming <[email protected]> wrote: > ... > g (1 : 0) > g=.+: > u y > ) > > nothing was resolved in the binding. Though its still a bug imo. > ...
It's never a bug just because the computer does not read your mind (or, more precisely, does not understand your intent). But let me explain: There are three issues at stake here: (1) the definition of the argument (2) the locale containing that definition (3) potential updates of that definition Purists might argue that we should ignore the possibility of updates. (Functional language purists.) But the above example is a case where we update the definition of the argument before using it. Here's an example where we extract the definition of the argument before using it (which gives us an error if there was no definition): g (1 :0) u f. y ) But using f. introduces two problems: (a) we lose track of the locale which contained the definition, and (b) we also can lose track of the locale parts of the definition (which could have been different from that of the definition). I'm not going to provide examples of these, here, but you should be able to construct some yourself. (Or: ask me, and I can provide some in another message.) We can avoid (b) by using the more verbose ((5!:1 <'u') 5!:0) in place of (u f.) The only way, though, to find the locale is to examine the name itself and parse it (and if indirection is used, extracting the indirectly referenced locale). A consequence of this issue is that the jtrace facility will give you value errors if you try to trace definitions which are in a different locale from the trace facility (such as the base locale). [But note also that the jtrace facility was originally defined in the base locale and was moved to its own locale to avoid problems with name collisions. (The ideal approach, in my mind, would involve building a facility to extract the locale and using that locale when resolving execution steps in jtrace. Now that I think this through, I think I can do a passable job of that.) Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
