Re: [SLOF] [PATCH v3] slof/fs/packages/disk-label.fs: improve checking for DOS boot partitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 28, 2024 at 10:09:20AM +0530, Kautuk Consul wrote:
> On 2024-03-27 08:43:25, Segher Boessenkool wrote:
> > If an exception happens you can (should!) throw an exception.  Which
> > you can then catch at a pretty high level.
> Ah, correct. Thanks for the suggestion! I think I will now try to throw
> an exception from read-sector if all the code-paths imply that a "catch"
> is in progress.

Don't try to detect something is trying to catch things.  Just throw!
Always *something* will catch things (the outer interpreter, if nothing
else), anyway.  In SLOF this is very explicit:

: quit
  BEGIN
    0 rdepth!    \ clear nesting stack
    [            \ switch to interpretation state
    terminal     \ all input and output not redirected
    BEGIN
      depth . [char] > emit space  \ output prompt
      refill WHILE
      space
      ['] interpret catch          \ that is all the default throw/catch
                                   \ there is!  no special casing needed
      dup print-status             \ "ok" or "aborted" or abort" string
    REPEAT
  AGAIN ;

The whole programming model is that you can blindly throw a fatal error
whenever one happens.  You cannot deal with it anyway, it is fatal!
That is 98% or so of the exceptions you'll ever see.  Very sometimes it
is used for non-local control flow.  That has its place, but please
don't overuse that :-)


Segher




[Index of Archives]     [KVM Development]     [KVM ARM]     [KVM ia64]     [Linux Virtualization]     [Linux USB Devel]     [Linux Video]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux