That was not my solution, that was me quoting and reformatting someone else's work.
I have not attempted a solution, because I do not yet understand the problem. Thanks, -- Raul On Tue, Apr 25, 2017 at 3:13 AM, Xiao-Yong Jin <[email protected]> wrote: > Thanks for writing a long reply. I think it is better for us if I can > convince you that your solution does not work before discussing the > question about why. > > I've tried to rename my code so it should appear better to your standard. > > in_z_=:2 :'(u`'''' ,&(,&''_''@:,@:>) n)~' NB.accepts global named verb > > aGlobalName=:0 > verbUsesAGlobalName=:3 :0 > aGlobalName + y > ) > adv=:1 :0 > echo u`'' > u y > ) > f=:3 :0 > C=.conew'base' > aGlobalName__C=:2 > z=.verbUsesAGlobalName in C adv 0 > codestroy__C'' > z > ) > fMiller =: 3 : 0 > s =. coname '' NB. save current locale > C =. conew 'base' > aGlobalName__C=:2 > cocurrent > C > v =. verbUsesAGlobalName f. > cocurrent > s NB. restore current locale > v adv 0 > ) > > Now in J session, > > f'' > ┌──────────────────────┐ > │verbUsesAGlobalName_0_│ > └──────────────────────┘ > 2 > fMiller'' > ┌─────────────────────────────────┐ > │┌─┬─────────────────────────────┐│ > ││:│┌─────┬─────────────────────┐││ > ││ ││┌─┬─┐│┌─┬─────────────────┐│││ > ││ │││0│3│││0│ aGlobalName + y││││ > ││ ││└─┴─┘│└─┴─────────────────┘│││ > ││ │└─────┴─────────────────────┘││ > │└─┴─────────────────────────────┘│ > └─────────────────────────────────┘ > 0 > > As to why, short answer: hiding names for global states that are only useful > for a few verbs and avoid name clashing. > >> On Apr 24, 2017, at 11:31 AM, Raul Miller <[email protected]> wrote: >> >> I didn't read your code, because of how it was formatted when I >> received it. But that mostly probably means that I should have taken >> responsibility to reformat it. Thus: >> >> verbInClass_SomeClass_ =: plus >> plus_SomeClass_ =: + >> adv =: / >> >> NB. then how about this ? >> >> f =: 3 : 0 >> s =. coname '' NB. save current locale >> C =. conew 'SomeClass' >> cocurrent > C >> v =. verbInClass f. >> cocurrent > s NB. restore current locale >> v adv y >> ) >> >> But the real question should be: why would you want to do anything like this? >> >> Conceptually speaking, locales should be used as "modules" where >> administrative needs put different people on different tasks. The >> class / object system then allows their work to be combined - perhaps >> not efficiently, but reducing the name conflict issues to a relatively >> manageable level. But that just justifies direct locale references. >> >> The indirect locale reference thing doesn't have this justification. >> The only places I have used it have been in the implementation of >> specifications which were designed for other programming languages. >> The resulting code tends to be extremely inefficient, but that tends >> to not matter for those kinds of problems. >> >> Which leads back to the question: why would you want to do this? >> >> We need some practical use cases, I think, so that's really not a >> rhetorical question, though I suppose it also might have some >> rhetorical value... >> >> For now, as other people have indicated, the resulting complexity >> (from the language not internalizing support for this issue) seems >> manageable in most cases, but it does require some detailed thought >> and a careful understanding of the differences between names >> (references) and values (an issue which tends to expose "painful" >> differences across any pair of languages). >> >> Or, that's my current opinion. >> >> Thanks, >> >> -- >> Raul >> >> >> On Sun, Apr 23, 2017 at 1:37 PM, roger stokes <[email protected]> >> wrote: >>> NB. Suppose we have: >>> >>> >>> verbInClass_SomeClass_ =: plus >>> >>> plus_SomeClass_ =: + >>> >>> adv =: / >>> >>> >>> NB. then how about this ? >>> >>> >>> f =: 3 : 0 >>> >>> s =. coname '' NB. save current locale >>> >>> C =. conew 'SomeClass' >>> >>> cocurrent > C >>> >>> v =. verbInClass f. >>> >>> cocurrent > s NB. restore current locale >>> >>> v adv y >>> >>> ) >>> >>> >>> f 1 2 3 >>> >>> 6 >>> ---------------------------------------------------------------------- >>> 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
