Not all good ideas are good ideas..

15 views
Skip to first unread message

The Beez

unread,
Apr 26, 2025, 10:19:47 AMApr 26
to 4tH-compiler
Hi 4tH-ers!

"4tH uses only signed 32-bit (or 64-bit) cells, but some words in ANS-Forth, like '<#', '#>', 'FILE-SIZE', 'FILE-POSITION' and 'REPOSITION-FILE' require the use of double numbers. You can easily fix this by adding 'S>D', which converts a number to a double number. Its counterpart, 'D>S', is available too. In 4tH these words have no effect."

This has been the case since 4tH's inception. And in general, this worked pretty good - unless I REALLY wanted S>D. Now, when unsigned, U>D worked fine. When negative -S>D worked fine. But if I needed a vanilla S>D - we had a problem. Of course, I could define S->D, which was part of Forth-79 - but it always felt "off".

Since 4tH inception, a lot of functionality has been introduced. Like [IGNORE]. Do we could define S>D and its counterpart D>S like this:

[UNDEFINED] S>D [IF]
  [IGNORE] S>D
  [IGNORE] D>S
[THEN]

And it would work! But later I found out it could also be a source of horrible bugs. Let's assume we included a few libs which required double numbers. Hence, those words would never be ignored, because they're already defined.

On the other hand, we wanted to make a library portable and included those words. That library is followed by our previous library - which required true S>D and D>S.  Either it would bomb out during compilation or those words would be ignored.

In short, it would introduce a horrible logistical problem.

So, in short - we keep the previous solution. All of a sudden, S->D seems like a small price to pay.

Hans Bezemer


Reply all
Reply to author
Forward
0 new messages