Deutsch   English   Français   Italiano  
<70a3014f99baf5e43b32e1320d7b8cd482be04c1@i2pn2.org>

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

Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: dxf <dxforth@gmail.com>
Newsgroups: comp.lang.forth
Subject: Re: Parsing timestamps?
Date: Tue, 10 Jun 2025 12:31:51 +1000
Organization: i2pn2 (i2pn.org)
Message-ID: <70a3014f99baf5e43b32e1320d7b8cd482be04c1@i2pn2.org>
References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org>
 <7e21117d37c506cccd8e79323c416fd1@www.novabbs.com>
 <1021bsd$31o0d$1@dont-email.me>
 <b5802b3faad00b9a4397e1e445561681d0cd6ce5@i2pn2.org>
 <6ced001912d95b520dad9d25a6014342@www.novabbs.com>
 <60ca19340523b1ddfa4a2cbf1ac0995cb185cdcb@i2pn2.org>
 <nnd$16a55d5e$0e5ab22d@1d9c51e25014f149>
 <bdc732e87e38233e9e23f254b2326cf2@www.novabbs.com>
 <nnd$1a4144e5$43cad09f@b57c0b5013a1f2ab>
 <6ea4ccd1cb6ae8c828144444fe51fea9@www.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Jun 2025 02:31:55 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="4043303"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="XPw7UV90Iy7EOhY4YuUXhpdoEf5Vz7K+BsxA/Cx8bVc";
User-Agent: Mozilla Thunderbird
X-Spam-Checker-Version: SpamAssassin 4.0.0
In-Reply-To: <6ea4ccd1cb6ae8c828144444fe51fea9@www.novabbs.com>
Content-Language: en-GB

On 10/06/2025 6:00 am, LIT wrote:
> ... 
> Stack jugglery means wasting CPU cycles for
> moving the bytes around - it's contrproductive.
> Variables have been invented to be used. They're
> useful, if you didn't notice, or if they didn't
> tell you that in your college, or wherever.

Forth uses variables in the global sense and this works well.
Variables at the word level is often an indication something is
wrong.  Locals users rarely justify on grounds of performance as
experience over the years has shown time and again well-written
stack code is both shorter and faster.  The temptation is to
write one routine that does it all and this is where variables
and 'stack juggling' can sneak in.  OTOH some implementations
are just neater and its a matter of finding them!

: HMS>SEC ( s m h -- ud )  3600 um*  2swap  60 *  +  0  d+ ;

\ Parse HH:MM:SS or free-form  ref: sjack
: >HMS ( a u -- sec min hr )
  2>r  0 0 0  2r>  begin
    /int  5 -roll  rot drop  dup while  [char] : ?skip
  repeat 2drop ;

\ Parse HMS string returning #csecs
: /HMS ( a u -- ud )  >hms hms>sec  100 mu* ;