If/when I need globals in an application I put them in a special locale so they do not get mixed up with anything else.
I also make sure they have telling names and are in UPPERCASE Also CONSTANTS I put in a separate special locale. Separating names and organizing your applications in locales makes life really easy. 2011/9/27 Mark Niemiec <[email protected]> > Raul Miller <[email protected]> wrote: > > >> My reading of these two concepts suggests that x and y are sometimes > > >> prohibited as global names. ?And, it's easy enough to conduct an > > >> experiment to test this concept: > > >> > > >> ? 3 :'y=:0' 0 > > >> |domain error > > >> | ? y ? ?=:0 > > > > > > > > > This is not because y is forbidden as a global name. > > > > I do not think that "sometimes prohibited" and "forbidden" mean the same > thing. > > Use of global x and y is NEVER prohibited. They are just more difficult to > access, since one and/or the other is always masked by a local variable > within any explicit definition. However, these can easily be circumvented > by use of locales, or by stepping out of the definition, or using only > tacit > verbs. > > x =: 4 > y =: 3 > X =: 3 :'x' > Y =: 3 :'0(1 :''y'')' > v =: 4 : '(X+Y)0' > 10 v 20 > 7 > w =: 4 : 'x__+y__' > 10 w 20 > 7 > t =. ".@:('x'"_) + ".@:('y'"_) > 10 t 20 > 7 > > -- Mark D. Niemiec <[email protected]> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Björn Helgason, Verkfræðingur Fornustekkum II 781 Hornafirði, t-póst: [email protected] gsm: +3546985532 twitter: @flugfiskur http://groups.google.com/group/J-Programming Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans góður kennari getur stigið á tær án þess að glansinn fari af skónum /|_ .-----------------------------------. ,' .\ / | Með léttri lund verður | ,--' _,' | Dagurinn í dag | / / | Enn betri en gærdagurinn | ( -. | `-----------------------------------' | ) | (\_ _/) (`-. '--.) (='.'=) ♖♘♗♕♔♙ `. )----' (")_(") ☃☠ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
