On Thu, Sep 6, 2012 at 3:39 PM, Ian Clark <[email protected]> wrote:
> Re-reading this thread I think my terse reply could be taken for curt.
> I apologise if this has given offence.
No offense taken.
Disorientation on the other hand? I have been taking some of that...
> 1. Is there a recommended way of doing this, viz offerring and
> specifying a load with a mode qualifier?
>
> 2. Is there a need for such a facility? In what form?
>
> From your reply I can infer the answer to 1. is No. Because otherwise
> you would have pointed me at it.
This is not strictly the case. However, It Is Not That Simple (and
maybe I want to keep my disorientation to myself...)
> On the other hand there might indeed be a recommendation, which is
> Don't Do It. And Don't Even Think Of It, because it risks causing a
> lot of trouble for the implementation of "require".
For some cases of "load differently", yes, this is the probably the
case. Specifically, if there are significant differences which are
visible after the load, I would advise against "modal loading".
However, for other cases of "load differently", it might be no big
deal. Specifically, if you only notice the differences while the
files are being loaded (for example: optional diagnostics being
emitted to the session, describing the progress of the load), then
this could be a reasonable thing.
...
> I do need a way of loading different combinations of scripts when my
> proposed addon 'misc/zulu' is first loaded. If there's no recommended
> way of doing this then I'll cobble up my own. But It would be nice if
> the different "load" options were (almost) as easy to specify as a
> simple "load misc/zulu" . I would expect the user of "require" to
> accept the addon in whatever mode it has been loaded, and to
> understand that any mode qualifier only applies on first loading.
If your requirement is to actually load different contents, then I
would present this as different files to be loaded (or required).
In other words:
require 'misc/zulu/normal'
NB. or
require 'misc/zulo/trace'
Note also that the "trace" file(s) could require the "normal" file(s),
if that helps you. (But why would you not want to be able to switch
trace on and off after the load?)
If your requirement is to give optional diagnostics on the loading
process then I would check for the existence of a control variable in
a locale which is "owned" by your loading process.
In other word:
load 'misc/zulu' [ TRACE_zulu_=: 1
Your implementation might then look something like this:
cocurrent 'zulu' NB. or coclass...
...
3 :0''
if. 0 = nc <'TRACE' then.
NB. debug stuff goes here
end.
)
Here, a bare load would get normal behavior. Defining the name with a
noun would get the debug behavior. If you like you could forcibly
turn the load tracing behavior off, after possibly previously enabling
it:
load 'misc/zulu' [ erase 'TRACE_zulu_'
I hope this helps,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm