• Re: Number parsing with checks

    From mhx@21:1/5 to Ruvim on Sat Oct 12 16:40:07 2024
    On Sat, 12 Oct 2024 14:46:52 +0000, Ruvim wrote:

    On 2024-10-12 17:54, Ruvim wrote:
    On 2024-10-12 05:45, dxf wrote:
    The basics:
    [..]
    : ZE? ( x -- )  if .bad then ;     \ abort if non-zero
    : NZ? ( x -- )  0= ze? ;           \ abort if zero

    Typically, if word name ends with a question mark, the first (top)
    output parameter of the word is a *flag*. And it's true for all
    standard words. (though, opposite is not true)

    These are better names and narrower stack diagrams:

      DROP-NZ ( x\0 --  |  0 -- never )
      DROP-ZE ( 0 --  |  x\0 -- never )

    I do not like these names too.

    These seem better:

    ?NZ-DROP
    ?ZE-DROP
    [..]

    My convention has always been that if a word starts with
    a '?', it tests and [possibly] aborts. This makes
    '-DROP' unnecessary.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stephen Pelc@21:1/5 to All on Mon Oct 14 14:21:20 2024
    On 12 Oct 2024 at 18:40:07 CEST, "mhx" <mhx> wrote:

    My convention has always been that if a word starts with
    a '?', it tests and [possibly] aborts. This makes
    '-DROP' unnecessary.

    The same convention is used by MPE, but I'm sure that there are exceptions
    in our code.

    Stephen
    --
    Stephen Pelc, stephen@vfxforth.com
    MicroProcessor Engineering, Ltd. - More Real, Less Time
    133 Hill Lane, Southampton SO15 5AF, England
    tel: +44 (0)78 0390 3612, +34 649 662 974
    http://www.mpeforth.com
    MPE website
    http://www.vfxforth.com/downloads/VfxCommunity/
    downloads

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)