Sujet : Re: May the numbers speak - supplement
De : the.beez.speaks (at) *nospam* gmail.com (Hans Bezemer)
Groupes : comp.lang.forthDate : 13. Jun 2025, 13:44:18
Autres entêtes
Organisation : KPN B.V.
Message-ID : <nnd$60801ebf$673609a7@27f3ceb479661625>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Mozilla Thunderbird
On 13-06-2025 06:46, dxf wrote:
On 13/06/2025 8:24 am, B. Pym wrote:
: keep { lo hi adr len } lo adr len ;
: get { adr len } 0. adr len >number keep 1 /string ;
: hms ( adr len -- h m s) get get get 2drop ;
: test clearstack s" 12:34:56" hms ;
Not worth the locals IMO. OTOH I guarantee (number) will be re-used.
: (number) ( adr len -- ud adr' len' ) 0. 2swap >number ;
: get ( adr len -- u adr' len' ) (number) rot drop 1 /string ;
: hms ( adr len -- h m s) get get get 2drop ;
: test clearstack s" 12:34:56" hms ;
That's why I consider the use of global variables in library functions worse than locals. You're polluting the namespace.
In 4tH I can introduce and remove them from the namespace within the same module. That's done by simply kicking them individually (and not the whole shebang after it) from the symbol table.
But still, I don't like to introduce new symbols. What if the user had his own library - and didn't take those precautions? He'll be wondering "Why is this thing complaining - instead of compiling?"
That's also the reason I didn't define stuff like "ERROR" - since that is more likely to be used by end-users. Also guilty: I haven't documented all "publics" from all libs - so there is nothing to fall back on. On the other hand - I'd like to keep my sanity. More things documented means more things to maintain.
Hans Bezemer