Say I want to release an addon called: misc/zulu. It has a choice of
modes to load it in. These modes set tracing or include optional
verbs, builds system data differently etc.

As it loads, zulu.ijs expects to see a system flag somewhere (call it:
LOADMODE_j_) to run conditional code or set its own flags.

1. Is there already a recommended way for the addon developer to offer
this facility?

2. I have a few ideas how it should look to the user. (For 'require'
you can read 'load') ...

   require 'misc/zulu' [ LOADMODE_j_=: 3                NB. yuk!  (You have to 
know
all about the flag)

   require '~addons/misc/zulu/zulu3.ijs'                        NB. yuk^2

   require 'misc/zulu3'                                         NB. Multiple 
separate addons that use
common code. Tiresome to maintain.

   require 'misc/zulu?3'                                                NB. IMO 
much better. Sets LOADMODE_j_=:
3 prior to loading.

   require 'misc/zulu?TRACE'                                    NB. Can we 
relax +ve integers? Sets
LOADMODE_j_=: 'TRACE'

   require 'misc/zulu'?ZULUMODE=:3'                     NB. Ignores LOADMODE_j_ 
and
executes ZULUMODE=:3 at some stage (??!)

A '?'-suffix will need changes to getscripts_j_ . But not to mess
around with LOADED_j_ .

Sundry question: what if runs:  require 'misc/zulu?3' --and misc/zulu
already loaded in mode 2?
-I propose "require" is then a no-op. If the user wants to force mode
3 then s/he'll have to "load".

Any comments?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to