The exit mechanism, throws, errors and returns are basically your options. You can combine them, of course. For example, you can catch a throw and then return. Or you can run a J instance in a separate process and then exit from that and return from the routine that started the process. Or maybe you want to use a stop-on-error script or adverse to regain control -- http://www.jsoftware.com/help/dictionary/dx000.htm or http://www.jsoftware.com/help/dictionary/d312.htm
Ultimately... what you're talking about is a bit ugly and whatever you choose is going to have some warts. If you wanted clean, though, you'd redesign and rebuild. Good luck, -- Raul On Sat, Dec 30, 2017 at 7:48 PM, Nick S <[email protected]> wrote: > Well, exit'' takes J down completely. > > I have read through most of the foreigns again, and through doc, and I > searched the messages from this forum for a bit. Either I can't find the > right search string or it has not been discussed since I have begun > following this. I just can't find an answer. > > I have a deeply embedded function that discovers that it has completed the > task set before it. (This is a continuation of my solitare game solver). > I am doing trial solutions - and if everything works. it will declare a > solution and end. > > This function was not part of the initial design. It would be inconvenient > for me to return and then set a flag so that the top level solver code > emits the right messages, although I could do that. > > Instead I was hoping to, from whatever level of recursion I have reached is > doing trial solutions, to decide that I have met the burden of "being > done". and simply return to the console prompt, allowing the stack to be > thrown away. > > I suppose I could execute the entire thing under a try. and throw back to > it. > Is throw the only way to do this? I guess I could just use an uncaught > throw, as: > > > foo =: 3 : 'if. y > 64 do. y throw. else. foo >: y end. ' > > foo 1 > > $ foo 1 > > # foo 1 > > Is the answer as simple as an uncaught throw or is there a "right" way? > > I searched for "uncaught throw" and found > uncaught throw. gives no message > > Now it does: error code 35, 'uncaught throw.' > > Henry Rich <http://code.jsoftware.com/wiki/User:Henry_Rich> (talk > <http://code.jsoftware.com/mediawiki/index.php?title=User_talk:Henry_Rich&action=edit&redlink=1>) > 15:06, 4 June 2017 (UTC) > > So that is probably something that I should not use because it will be > fixed, I just don't have it yet. I don't want to mess with the debugger. > I guess I could make a master catcher that runs everything but then I have > to pass on errors or I get nothing when I have a bug. > > I'll admit I am being lazy. I am trying to add trial and error to a solver > that works whenever there is enough info in the puzzle specification, but > when there is not, the next trick is to try blocks in various positions, > and when you get impossible progressions, you can eliminate a space and > then try again. I might be descended through several layers as the > solution is found. > -- > Of course I can ride in the carpool lane, officer. Jesus is my constant > companion. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
