>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Primer

Plot locale

Plot also illustrates a common technique in the use of locales. Close J and restart it to get a clean slate. The names in the base locale is empty and there are just the two standard locales that are populated by the profile.ijs script.
   names 3	NB. verbs
   names 6	NB. locales
base j    jcfg z
The load verb (defined in the z locale) loads the plot.ijs script into the plot locale.
   load 'plot'
   plot ? 5 $ 100	
   names 3
   names 6
base  j     jcfg  jplot z
   plot
+----------+
¦plot_plot_¦
+----------+
The verb plot is not defined in the base locale, but is defined in the z locale. When it is executed in the base locale the definition from the z locale is executed as if it were in the base locale. Entering the name plot displays its definition. The interesting thing about the definition of plot is that it executes the plot verb in the plot locale. So the plot in the z locale is a cover that works in all locales and has the result of executing plot in the plot locale.

This technique of loading a facility like the plot package into its own locale, and then defining cover verbs in the z locale so that plain name references invoke the desired verb in the facility locale is common. The definitions in the plot locale can be viewed as the private implementation of the facility and the names that are exposed by being defined in the z locale are the public or published interface.

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Primer