Re: Number parsing with checks

Liste des GroupesRevenir à cl forth 
Sujet : Re: Number parsing with checks
De : ruvim.pinka (at) *nospam* gmail.com (Ruvim)
Groupes : comp.lang.forth
Date : 12. Oct 2024, 15:46:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vee24s$6b05$2@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 2024-10-12 17:54, Ruvim wrote:
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 )
I do not like these names too.
These seem better:
     ?NZ-DROP
     ?ZE-DROP

 
: ?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 <https://github.com/ ForthHub/discussion/discussions/171#discussioncomment-10882259>
 (this can be discussed there, or in a new thread here)
   -- Ruvim
 

Date Sujet#  Auteur
12 Oct 24 * Number parsing with checks17dxf
12 Oct 24 `* Re: Number parsing with checks16Ruvim
12 Oct 24  +* Re: Number parsing with checks4Ruvim
12 Oct 24  i`* Re: Number parsing with checks3mhx
12 Oct 24  i +- Re: Number parsing with checks1Ruvim
14 Oct 24  i `- Re: Number parsing with checks1Stephen Pelc
13 Oct 24  `* Re: Number parsing with checks11dxf
13 Oct 24   `* Re: Number parsing with checks10Ruvim
13 Oct 24    +* Re: Number parsing with checks8dxf
13 Oct 24    i`* Naming conventions (was: Number parsing with checks)7Ruvim
13 Oct 24    i `* Re: Naming conventions6dxf
13 Oct 24    i  +* Re: Naming conventions3Ruvim
13 Oct 24    i  i+- Re: Naming conventions1mhx
14 Oct 24    i  i`- Re: Naming conventions1dxf
14 Oct 24    i  `* Re: Naming conventions2Ruvim
14 Oct 24    i   `- Re: Naming conventions1dxf
14 Oct 24    `- Re: Number parsing with checks1dxf

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal