Re: Naming 'n' instances or repetitions

Liste des GroupesRevenir à cl forth 
Sujet : Re: Naming 'n' instances or repetitions
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forth
Date : 24. May 2025, 04:04:34
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <4b3e8950c219fcbf14d58734eb58b93935b6156c@i2pn2.org>
References : 1 2
User-Agent : Mozilla Thunderbird
On 23/05/2025 9:45 pm, Hans Bezemer wrote:
On 22-05-2025 05:34, dxf wrote:
I've noticed two ways of naming things 'done n times'.
>
In SwiftForth there is:
>
   (.0) (H.0)
>
which equate to executing '#' 'n' times.
>
It's not clear to me why '0' was used though '0' appears in forth naming
conventions meaning 'initialization'.
>
In VFX Forth (and perhaps others) there is:
>
   NDROP
>
where 'n' indicates number of executions.
>
In DX-Forth I have:
>
   NHOLD (H.N)
>
mainly because I couldn't think of anything else but willing to change
if there were a consensus.
>
Does anyone have knowledge on the matter or conventions etc.?
 
I consulted "Thinking Forth", but there's nothing directly relevant there. What I *DO* tend to do is to take a hash (#) as an indicator for "number". It can be positional (ERROR#), quantum (#ELEMENTS) - unless it is a quantum "per" thing (/ELEMENT).
 
It has to be a "fixed" quantum though. E.g. if there was no such thing as LEAVE or UNLOOP, I'd have no problems using a word like #DO - and something like #MOVE or #FILL wouldn't get any criticism from me too.
 
So, if I'd have to drop a number of elements I'd call it #DROP. The problem I have with "N" as a prefix is that it might be confusing. E.g. NEAT is a boolean for something cool - or the number of times something is eaten?

Agreed 'N' could be confusing.  For me the question is whether the two functions are
worth renaming.  Neither is particular popular.  OTOH perhaps they ought to be ...

  \ Hex formatted
  : (H.)  ( u -- adr len )  [ 2 cells ] literal (h.n) ;
  : (HW.) ( u -- adr len )  4 (h.n) ;
  : (HB.) ( u -- adr len )  2 (h.n) ;

  : (HD.) ( ud -- adr len )
    (h.) holds  (h.)  [ -2 cells ] literal /string ;

  \ Return string right-aligned as a2 u2. Uses HOLD buffer
  : RJUST ( a u width char -- a2 u2 )
    >r  over - 0 max >r  <#  2dup holds  r> r> nhold  #> ;

  : (S.R) ( a u +n -- a2 u2 )  bl rjust ;


Date Sujet#  Auteur
22 May 25 * Naming 'n' instances or repetitions9dxf
22 May 25 +* Re: Naming 'n' instances or repetitions2Anton Ertl
22 May 25 i`- Re: Naming 'n' instances or repetitions1dxf
23 May 25 +- Re: Naming 'n' instances or repetitions1dxf
23 May 25 +* Re: Naming 'n' instances or repetitions2Hans Bezemer
24 May 25 i`- Re: Naming 'n' instances or repetitions1dxf
24 May 25 `* Re: Naming 'n' instances or repetitions3Ruvim
24 May 25  +- Re: Naming 'n' instances or repetitions1albert
25 May 25  `- Re: Naming 'n' instances or repetitions1dxf

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal