Deutsch   English   Français   Italiano  
<vefh7p$hbo1$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Ruvim <ruvim.pinka@gmail.com>
Newsgroups: comp.lang.forth
Subject: Naming conventions (was: Number parsing with checks)
Date: Sun, 13 Oct 2024 08:10:32 +0400
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <vefh7p$hbo1$1@dont-email.me>
References: <636c943eae41d9a5832ce5a94414cb81be04a44f@i2pn2.org>
 <vedv35$6b05$1@dont-email.me>
 <59b4fdfd0718fbe6e37c645925b7bf0b5ac86dde@i2pn2.org>
 <vefaq8$gn8u$1@dont-email.me>
 <9bb57132c366402e72186ec8bbfe7eefdf085bbb@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 13 Oct 2024 06:10:33 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="055583f00555671c87854758fc8e0208";
	logging-data="569089"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX190IF23QVGfhTshpd1C7hkK"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BL1Hj4KP+dOwBLJrIVP//3abvGA=
In-Reply-To: <9bb57132c366402e72186ec8bbfe7eefdf085bbb@i2pn2.org>
Content-Language: en-US
Bytes: 3587

On 2024-10-13 06:59, dxf wrote:
> On 13/10/2024 1:20 pm, Ruvim wrote:
>> On 2024-10-13 05:13, dxf wrote:
>>> 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
>>
>> But these words do not return a flag in the first output parameter. So, their names violate the common convention.
> 
> Conventions are a guide.  Thankfully they're not yet a law.
> 

Sure. But the mentioned conventions seem good.

If you are proposing generally useful words, and their names violate a 
common convention, you could probably explain why it is not worth 
following that convention in this case (or in general).

Or perhaps you could add a note that these names violate a certain 
convention simply because better names have not been found yet.




In general, there are two groups of words that do something or do 
nothing depending on some conditions:
   - group1: the words that only test some parameters (on the stack 
and/or in memory);
   - group2: the words that consume some parameters from the stack.

The first group is larger than the second.


In your case, you want to have a word from the first group and the 
corresponding word from the second group. So, a new naming rule is 
needed to distinguish these words.

The actual difference between these groups for your words is one "DUP" 
or "DROP". E.g.:

   : ?NZ(group1)  DUP ?NZ(group2) ;

   : ?NZ(group2)  ?NZ(group1) DROP ;

If I had to choose only one word from these two, I would prefer the word 
from the first group.

So, if the corresponding word from the second group is rarely needed, it 
might not be worth introducing. Simply use "?NZ DROP" instead of an 
individual word. Profit: no need to find a new naming rule.

Possible words/names for internal use:

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



--
Ruvim