Sujet : Re: Number parsing with checks
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 13. Oct 2024, 02:13:32
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <59b4fdfd0718fbe6e37c645925b7bf0b5ac86dde@i2pn2.org>
References : 1 2
User-Agent : Mozilla Thunderbird
On 13/10/2024 12:54 am, 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)
It's rather similar.
ZE? NZ? destructively tests TOS
?ZE ?NZ non-destructively tests TOS
Only difference is test and action are rolled into the one function.