Re: Small, understandable Forth



Josh Grams <josh@xxxxxxxxxxx> writes Re: Small, understandable Forth

Marcel Hendrix wrote: <26230829113558@xxxxxxxxxxxxxx>
Josh Grams <josh@xxxxxxxxxxx> writes Re: Small, understandable Forth
[..]
But how much of the language do those applications exercise? Do they
use :NONAME extensively, or files, or exceptions, or ACCEPT, or have an
extensive test suite using MARKER to restore the dictionary between
sections? Each of these things is buggy on at least one supposedly
standard Forth system.

For this statement to be true there only needs to be a single crummy
(or unmaintained, as there's no such thing as bug-free code) Forth system.

Hmm. What if I put it like this? With the possible exception of
gforth, I am not aware of any free software Forth system whose release
version behaves as specified by the standard in all respects. Many of
these differences can be worked around (and depending on your
programming style, you may not even notice any of them), but it can be
surprisingly difficult to get a Forth program to run on many different
systems, even though they all claim to be standard.

Some additional comments based on my own explorations because it was hard
to believe the situation would be so serious.

You mentioned 4p, FICL, PFE, pforth and SP-Forth and Gforth. Judged by CLF
postings and your comments I expected PFE and SP-Forth and maybe pforth
to be usable. I downloaded pforth for Windows because I didn't know it.

Going by the file dates, pForth obviously hasn't been touched since 1998.
Indeed, the CATCH/THROW in catch.fth is simply wrong (trivial stack error).
This can be shown by its own example and test code at the end of the file.
I conclude this system is either not used by anyone or its maintainer
doesn't know how CATCH is supposed to work. That spells doom for less
esoteric language features. I also noted negative ALLOT and TIME&DATE are
not supported.

Next I downloaded SP-Forth. It starts off with an impressive installer.
However, it takes (too) MANY seconds to start up (?), is non-ANS, needs
to be told in all UPPERCASE and its help and docs are in Russian. I could
fix the uppercase and non-ANSness by including two files. Very nicely
done HTML help, at least/only for these two problems. Next I found that
the console window refused to work properly (couldn't set size and insert
mode etc.) Cut and paste didn't work, which was very awkward. Apparently,
after startup you can only use the system menu once (which should be enough,
of course). Although I made the console window very wide, SP-Forth uses a
line length of 80 characters whatever I did (minor issue, but not nice).

: test 0 do loop ;
1000000000 test 7 emit
... took about 5 seconds (iForth: 1.2 seconds) , although the code is
beautiful (only and inc [esp] and a jno ):

see test

57695B 8945FC MOV FC [EBP] , EAX
57695E 33C0 XOR EAX , EAX
576960 BA00000080 MOV EDX , # 80000000
576965 2B55FC SUB EDX , FC [EBP]
576968 8D1C02 LEA EBX , [EDX] [EAX]
57696B 8B4500 MOV EAX , 0 [EBP]
57696E 8D6D04 LEA EBP , 4 [EBP]
576971 6881695700 PUSH , # 576981
576976 52 PUSH EDX
576977 53 PUSH EBX
576978 FF0424 INC [ESP]
57697B 71FB JNO 576978
57697D 8D64240C LEA ESP , C [ESP]
576981 C3 RET NEAR

Apparently the developers theorize but don't test :-)

There is indeed (per your notes) something wrong with ENVIRONMENT?

S" BLOCK" ENVIRONMENT?
S" BLOCK ENVIRONMENT?
^ -35 Illegal block number

This is a well-known problem, some of the environment queries overlap
regular Forth names.

The result of including benchmark.f was a reproducible disaster:

-- ---------------------------------------------------------------------------
S" samples/bench/benchmark.f" INCLUDED
start isn't unique (samples/bench/benchmark.f)
..S isn't unique (lib\include\tools.f)
? isn't unique (lib\include\tools.f)
AHEAD isn't unique (lib\include\tools.f)
[ELSE] isn't unique (lib\include\tools.f)
[IF] isn't unique (lib\include\tools.f)
[THEN] isn't unique (lib\include\tools.f)
[DEFINED] isn't unique (lib\include\tools.f)
[UNDEFINED] isn't unique (lib\include\tools.f)
GetTickCount isn't unique (samples/bench/benchmark.f)
M+ isn't unique (samples/bench/benchmark.f)
u2/ isn't unique (samples/bench/benchmark.f)

Loading benchmark routinesCARRAY isn't unique (samples/bench/benchmark.f)
Threshold isn't unique (samples/bench/benchmark.f)
NIL isn't unique (samples/bench/benchmark.f)


Benchmark code size = 140037 bytes.

This system's primitives using no extensions

Test time including overhead ms times ns (each)
DO LOOP 0 5000000 0
+ 0 5000000 0
M+ 32 5000000 6
* 31 5000000 6
/ 94 5000000 18
M* 31 5000000 6
M/ 78 5000000 15
/MOD 94 5000000 18
*/ 109 5000000 21
ARRAY fill 0 1000000 0
Total: 484 1


This system's O/S interface using no extensions

Test time including overhead ms times ns (each)
Win32 API: SendMessage 63 500000 126
Win32 API: GetTickCount 140 2000000 70
System I/O: KEY? 985 80000 12312
Total: 1188 1


This system's application performance using no extensions

Test time including overhead ms times ns (each)
Eratosthenes sieve 1899 Primes 78 8190000 9
Fibonacci recursion ( 35 -> 9227465 ) 141 9227430 15
Hoare's quick sort (reverse order) 109 2000000 54
Generate random numbers (1024 kb array) 110 262144 419
LZ77 Comp. (400 kb Random Data Mem>Mem) 140 1
Dhrystone (integer)EXCEPTION! CODE:C0000005 ADDRESS:00552E12 WORD:CMOVE
USER DATA: 00341E94 THREAD ID: 00000F6C HANDLER: 0012EF84
STACK: (5) 80000001 7C817077 148D12C7 148D1518 0059A781 00000000 [0000001F]
RETURN STACK:
0012EF38 : 00553DC3 MOVE
0012EF3C : 0059A7BD Proc0
0012EF40 : 7FF85EE0
0012EF44 : 7FF85EE0
0012EF48 : 0059A933 Proc0
0012EF4C : 0034868C
0012EF50 : 003487A4
0012EF54 : 00000000
0012EF58 : 00000000
0012EF5C : 00000002
0012EF60 : 00000003
0012EF64 : 00000000
0012EF68 : 00000000
0012EF6C : 0059A9C9 $DHRY$
0012EF70 : 0059AE07 BENCHMARK
0012EF74 : 00567C5B INTERPRET_
0012EF78 : 00567CE2 INTERPRET
0012EF7C : 00568371 TranslateFlow
0012EF80 : 0055516C CATCH
0012EF84 : 0012EFC4
0012EF88 : 0012FFC0
0012EF8C : 0056819B RECEIVE-WITH-XT
0012EF90 : 00347E34
0012EF94 : 00000006
0012EF98 : 00000010
0012EF9C : 00000026
0012EFA0 : 003432E0
0012EFA4 : 00000026
0012EFA8 : 00000000
0012EFAC : 00000000
0012EFB0 : 005681EF RECEIVE-WITH
0012EFB4 : 005683AF INCLUDE-FILE
0012EFB8 : 0000008C
0012EFBC : 00568483 (INCLUDED1)
0012EFC0 : 0055516C CATCH
0012EFC4 : 0012EFE8
0012EFC8 : 0012FFB8
0012EFCC : 00568523 INCLUDED_STD
0012EFD0 : 00000000
0012EFD4 : 0056CB39 Included
0012EFD8 : 00567C5B INTERPRET_
0012EFDC : 00567CE2 INTERPRET
0012EFE0 : 00567F09 MAIN1
0012EFE4 : 0055516C CATCH
0012EFE8 : 0012EFF8
0012EFEC : 0012FFC0
0012EFF0 : 00567F59 QUIT
0012EFF4 : 0055516C CATCH
0012EFF8 : 00000000
0012EFFC : 0012FFC0
0012F000 : 0056B07D ERR-EXIT
0012F004 : 0056BC66 (INIT)
END OF EXCEPTION REPORT
Exception #-1073741819 at: samples/bench/benchmark.f:1454:9:
BENCHMARK
^ 0xC0000005L ACCESS_VIOLATION
-- ---------------------------------------------------------------------------

Apparently nobody has run this example ever.

I tried floating point. Apparently one needs to load float.f. The FPU
stack is used, which rules out recursion etc.. Fast but impractical, but
maybe there's a better implementation that I couldn't find.

Eventually I set up the following ini file:

\ spf4.ini

WARNING 0!

REQUIRE QuickSWL ~pinka\spf\quick-swl3.f
REQUIRE HELP lib\ext\help.f
STARTLOG

S" lib/include/ansi.f" INCLUDED
S" lib/ext/locals.f" INCLUDED
S" lib/ext/caseins.f" INCLUDED
S" lib/ext/disasm.f" INCLUDED
S" lib/include/float.f" INCLUDED

-1 WARNING !

I didn't dare generate the true windows executable that one has to
compile one-self, sorry.

Let's just say that SP-Forth has the potential to become a very useful
Forth, but at the moment it is wishful thinking to hope it can be
interchangeably used with other ANS Forths.

That left PFE. It currently uses a compression algorithm I can't handle,
so I must accept your judgement that it is unusable also. Looking
at its sourceforge page it does seem that guidod is very actively
maintaining it: 2009-10-17 release 0.33.71 with many albeit minor
cleanup changelog items. Strange that he wouldn't react to real bug
reports.

but it can be
surprisingly difficult to get a Forth program to run on many different
systems, even though they all claim to be standard.

It wasn't clear to me that you meant free systems.

It would be more constructive to be specific here (which Forth, which
feature).

That seems irrelevant to me: the point is that, depending on what you're
doing, you can't just pick up a free system and expect it to run your
programs correctly. Also I have (I think) reported all of these to the
maintainers of the systems in question, so it didn't occur to me to
mention them again.

OK, apparently the free systems situation is worse than I thought.

The systems I have tried so far which claim some standard-compliance are
4p, FICL, gforth, PFE, pforth, and SP-Forth.

"Some" is not enough for your specific purpose. Most free systems seem
to be quite keen on stressing deliberate ANS unfriendliness / deviations.

I haven't really tried
ciforth yet, and since I don't have a Windows machine, I have only tried
Win32Forth briefly under Wine. I think those are all the serious free
standard systems that I know of. If you know of other such systems
which run under Linux (x86 and preferably PPC as well), I'd be glad to
hear of them.

Win32Forth was very good last time I tried it. It is tied to windows,
but it can be used without noticing that at all (apart from not running
on Linux or OSX). ciforth is rock stable but doesn't do floating-point
and AFAIK doesn't interface to system libraries.

I thought I had a list of bugs somewhere, but I can't find it. So
here's a list off the top of my head:
[..]

See my additions above.

That's all I can think of right now...

-marcel

.



Relevant Pages

  • Re: Windows XP Search for meta in content does not work
    ... To configure Windows XP to search all files no matter what the file type, ... file types with unknown extensions option. ... Click Change Indexing Service Settings. ... Warning Serious problems might occur if you modify the registry incorrectly ...
    (microsoft.public.windowsxp.general)
  • Re: Downloading of files a problem
    ... Have you changed the default setting so that you can at least SEE the extensions? ... Hide protected operating system files (Recommended) ... If you click Run, instead of Save, Windows will put the file in a temporary location that may be hard for you to find later. ... This problem is on every download I try, ...
    (microsoft.public.windows.file_system)
  • Re: The future of FrontPage / FrontPage Extensions
    ... Unix, Windows 2000 Server, Windows XP Pro: Support ended in June 2006. ... There is a downloadable version of the 2002 extensions on the Microsoft site for all 64bit Windows operating systems. ... The FrontPage extensions use some non-standard code in places. ...
    (microsoft.public.frontpage.programming)
  • Re: Need advice for players and burning DVDs
    ... In Windows ... >extensions for known file types". ... >>The most prized files are .MKV files (matroska), ...
    (rec.video.dvd.players)