@Bill - I've been playing with this technique myself. Besides executing 13!:8, executing '@@' in the script will crash the verb: load, and a line of @@@… makes a visual signpost. The resulting error condition can be suppressed by using (load :: haltload). Even though load has notionally "failed", any word definitions created before failure persist.
> IF there are no anticipated errors in the script… Precisely. If haltload is (0:) then it suppresses ALL error messages, which is to set traps for oneself. But a more elaborate haltload can inspect the error condition (13!:11) (13!:12) and suppress only the syntax error when it hits a line of @@…, re-signalling all other errors. I wouldn't recommend this technique, because it's likely to misbehave with nested loads […untested]. As I've already said, I'd steer clear of schemes to abort the load, in favour of schemes which make a script behave like a shorter script, e.g. using 0!:101 (process_script_text) 1!:1 y , as per my script/scriptd example (which I'm using operationally), and as Martin reminds me. Others have hinted at schemes reminiscent of C/C++ compiler directives. I wondered if there was any mileage in introducing "interpreter directives" for J -- but quickly discarded the idea. They'd neither be easy nor safe to use nor easy to read. Note … ) is just as good -- though I prefer 0 :0 … ) because syntax coloring gives a visual confirmation of what gets commented-out. The only use I'd have is for a facility to (effectively) truncate a script, switchable by using different versions of (load). I could then run any script in one of two modes: development vs release. Three modes is a mode too far for me. It's something only a big corporation would concoct a use for. (…multi-platform scripts maybe??) On Thu, May 10, 2018 at 12:12 AM, bill lam <[email protected]> wrote: > IF there are no anticipated errors in the script, then one can put an > arbitrary sentence that will raise execution error such as 13!:8[3 at the > point of stop loading, and load the script and ignore the error, > 0!:0 ::0: foo > > the side effect of the portion already loaded should still remain. > > > On Thu, May 10, 2018, 6:55 AM Eric Iverson <[email protected]> > wrote: > > > I second Martin's comments about being wary of another level of > > meta-language for basic script load. > > > > There might be good arguments for custom loaders that handle things like > > this and more. But let's not overload load! > > > > > > On Wed, May 9, 2018 at 6:34 PM, <[email protected]> wrote: > > > > > Ian Clark wrote: > > > > > > > >Can I propose we agree to alter the stdlib verb: (load) to provide a > way > > > to > > > >stop loading a given script? > > > > > > > > @@NB. stop loading at this line > > > > > > > >certainly does that, but generates an unwelcome "syntax error". This > can > > > >interfere with calling processes. > > > > > > I'd be wary of establishing a meta-language/notation controlling script > > > loading. Enough tools exist to deal with your stop line, for example: > > > > > > 0!:101 ({.~ I.@('@@'&E.)) 1!:1 <'yourscript.ijs' > > > 0!:101 [ 2!:0 'sed "/^@@/{s///;q}" yourscript.ijs' > > > > > > Martin > > > ---------------------------------------------------------------------- > > > 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
