home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 116,870 of 117,927   
   Ruvim to dxf   
   Re: Number parsing with checks   
   12 Oct 24 17:54:45   
   
   From: ruvim.pinka@gmail.com   
      
   On 2024-10-12 05:45, dxf wrote:   
   > The basics:   
   >   
   > : .BAD ( -- )  cr ." Invalid item"  .abort ;   
   >   
   > : 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 )   
      
      
   > : ?ZE ( x -- x )  dup ze? ;        \ check x is zero   
   > : ?NZ ( x -- x )  dup nz? ;        \ check x is non-zero   
      
   Better stack diagrams:   
      
      ?ZE ( 0 -- 0  |  x\0 -- never )   
      ?NZ ( x.some\0 -- x.some  |  0 -- never )   
      
   I suggest to use the data type symbol "never" for the empty data type.   
      
   See my explanation about the empty data type at   
      
      
   (this can be discussed there, or in a new thread here)   
      
      
      
   --   
   Ruvim   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca