Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: dxf Newsgroups: comp.lang.forth Subject: Re: Naming 'n' instances or repetitions Date: Sat, 24 May 2025 13:04:34 +1000 Organization: i2pn2 (i2pn.org) Message-ID: <4b3e8950c219fcbf14d58734eb58b93935b6156c@i2pn2.org> References: <02c99c0785dce8043377d34b8ad339885e2d61d1@i2pn2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 24 May 2025 03:04:38 -0000 (UTC) Injection-Info: i2pn2.org; logging-data="1671357"; mail-complaints-to="usenet@i2pn2.org"; posting-account="XPw7UV90Iy7EOhY4YuUXhpdoEf5Vz7K+BsxA/Cx8bVc"; User-Agent: Mozilla Thunderbird Content-Language: en-GB In-Reply-To: X-Spam-Checker-Version: SpamAssassin 4.0.0 Bytes: 2996 Lines: 50 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 ;