From: the.beez.speaks@gmail.com   
      
   On 02-05-2025 14:16, albert@spenarnc.xs4all.nl wrote:   
   > In article ,   
   > Hans Bezemer wrote:   
   >> On 01-05-2025 03:23, dxf wrote:   
   >>> On 30/04/2025 11:58 pm, Hans Bezemer wrote:   
   >>>> On 30-04-2025 04:37, dxf wrote:   
   >>>>> On 30/04/2025 2:50 am, Hans Bezemer wrote:   
   >>>>>> ...   
   >>>>>> To force myself to add messages to THROWs (especially in libs with   
   special conditions) I added THROW" - it works like a combination of ABORT" and   
   THROW. You need to   
   >> specify a THROW code, you need to specify a flag and you need to specify a   
   message.   
   >>>>>   
   >>>>> What happens in the case of CATCH - what's left on the stack?   
   >>>>>   
   >>>> Surprise, surprise - THROW" calls THROW (actually, it inlines the whole   
   shebang). So - what do you think?   
   >>>   
   >>> For ABORT" the string is suppressed and only the code (-2) is left.   
   >>> Is that what THROW" does with the string?   
   >>>   
   >>> AFAIK on most forth systems exceptions generate either an error code or an   
   >>> error message (the latter via ABORT" or caught code). In short, what good   
   >>> is having both a msg and a code?   
   >>>   
   >>   
   >> In 4tH, ABORT is really abort. It does what the label says. It can't be   
   >> caught. If you want to abort, I assume you want to abort. If you wanna   
   >> catch it, use THROW. C'mon. I designed it as a man's language ;-)   
   >   
   > ABORT is at least kind of an exception. But look at QUIT.   
   > Actually QUIT is the READ-EVALUATE-PRINT-REPEAT loop of   
   > Forth. How can this ever be considered an exception or   
   > "caught".   
   > I struggled with giving a meaning to QUIT and ABORT.   
   > I arrived at   
   > QUIT initialises both stacks and goes interpreting.   
   > ABORT only initialises the return stack and goes interpreting.   
   >   
   > (if there is an exception system, both must initialise that too.   
   > I can't think of a QUIT that can be caught and at the same time   
   > initialises the exceptions.)   
      
   Well, since 4tH has no REPL QUIT equals ABORT. But I support your   
   interpretation of these words for a classical Forth system fully.   
      
   But in my system I wanted a "gimme-out-of-here" command. A few years ago   
   - as I'd created THROW" - I revisited all of my libraries and replaced   
   any ABORT" statements - because I feel libs shouldn't call ABORT".   
   That's for the application programmer.   
      
   4tH's runtime sets up the entire environment - also when PAUSEd. For   
   PAUSEing it uses the same frame as setting up for CATCH. Now the stack   
   pointers can only be manipulated by the VM, so I don't have to worry   
   about anyone messing with these. Again, you can look - but you can't   
   touch. Does that limit your capabilities as an application programmer?   
   Yes. Is it worth it? Most definitely IMHO.   
      
   As for "there may be other resources that have to be managed" -   
   completely true. That's why you examine the return value:   
      
   : (try) ( -- n)   
    frame >r dstack @ >r gstack @ >r fstack @ >r exec_gosub gstack a@ >r   
    ['] call catch dup \ save pointers and call procedure   
    if r> prog ! r> fstack ! r> gstack ! r> dstack ! r> to frame ;then   
    rdrop rdrop rdrop rdrop rdrop \ drop all saved pointers   
      
      
   This is the TRY() command of uBasic/4tH. It works with CATCH. It saves   
   the USER stack, the GOSUB stack, the FOR stack and the locals stack of   
   the language. So frankly - I don't see the problem, but maybe I'm just   
   too naive.   
      
   Hans Bezemer   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|