Tadpole Slamp in
FORTH PROGRAMMING LANGUAGE 21st CENTURY
Alright... time to get to something I should have gotten to a long time
ago. I'm not a forth programmer, but I have real reasons to
believe it is my favorite language (although, check out rebol, a new
language inspired by forth logo and scheme has GOT to be good!!).
I've got a very fundamental question, that could be interpreted as an
insult but it's not. Stacks. Is the use of the stack in forth a
beloved anachronism, like cdr in scheme, or r stacks extremely
useful/arguably the best data structure/memory scheme EVER, or
something in between? If not sentiment based, is there a text
that shows why/how stacks rock? A stack oriented into to forth or
something?!?!
| --
...
| --
Bob Armstrong
Stacks are minimal -- and essentially functional .
But to get to the useful human level the items on the stacks must
generally be addresses of typed objects , of which , again , the
minimal most generic is simply lists with the count of their items in
the header .
The header of a CoSy list is simply
`( Type Count RefCount )`
where
`( ... )`
returns a list of the words .
(
Type
Count
RefCount
)
`( Type Count RefCount )` DMP
00D8AED0 00 00 00 00 03 00 00 00 00 00 20 00 00 00 00 00 .......... .....
00D8AEE0 F0 7A D3 00 C8 04 D0 00 80 06 D0 00 00 00 00 00 .z..............
Type 0 is a list of lists .
CoSy in open Forth is more than anything else , far more ` flexible
than a traditional APL , the simplicity of it's natural RPN syntax ,
more pleasant , dissectible and understandable .
I'm finding the interplay between the stack and lists an unexpected synergy .
| --
Rod Newstrom > Bob Armstrong
in Forth the type is implicit to the operator rather than explicit to the data. This is both a strength and a weakness iMHO.
| --
Bob Armstrong > Rod Newstrom
Thus it is IMPOSSIBLE to have any ` genericity in verbs . And thus one is glued to simple chip level operations and algorithms .
On can never possible compete with a Python much less an APL .
That's why we see Dr Ting , for instance , using Python to do his
genome analysis . My aim is to see people implement the nub of the CoSy
vocabulary in the Forth of their choice leapfrogging Python .
Ilya V. Vasilyev > Rod Newstrom
, I haven’t. But if I am about to include registers in my CPU, at least
half of them can be implemented as memory on fixed locations from the
stack frame register. There are precedents. PDP-11 allowed to use any
register as base or offset pointer. EBP register is flexible enough on
Intel x86 architecture.
Hardware implementation can use fast on chip memory for stack and stack
frames, but locals can be implemented by software only as well.
|--
Bob Armstrong
Ilya's comment on registers and this conversation makes me think of having
`( Type Count refCount )`
registers which are loaded in parallel with the address of the list on the stack .
| --
Neal Orr > Bob Armstrong
Use
<BUILDS DOES>
(or
CREATE DOES>
)
to compile list header and data into a new named word that always uses
it properly. The header may be Count, the address is built-in to the
word.
Do you have a copy of Starting Forth? It's free. It let me do in 1983 what C++ let me do in 93... more places paid for C++.
Non-global variables are best be contained in an object with the words
that use them. It is easy to make state machine objects in forth.
Look for Download PDF,
https://www.forth.com/starting-forth/
| --
Bob Armstrong > Neal Orr
With all due respect , you are TOTALLY missing the wall which must be
scaled between the laying out of a static dictionary in a single
address space and the plateau of dynamic allocated address spaces , ie:
objects , underlying an APL level language .
The vocabulary you cite would be useful if the words took the base
address of the allocated address space as a parameter rather than
assuming ' here . In any case those sorts of fundamentals are at the
very early vocabulary at the machine level of CoSy .
I can't think of a good introduction to APL , and much of it becomes
excessively complex . You can get a sense of the level of the
vocabulary from http://www.cosy.com/K/html/kref.pdf .
When I say " leapfrog Python " I mean it . And by implication of course
C++ or any other such traditional language . ( Incidentally , you might
find this email exchange with Bjarne of interest :
http://www.cosy.com/language/bjarne.htm )
Trying to think of an example . CoSy is about
ec Words # |>| 942 |
words in Reva Forth .
Here are those header words :
`( Type Count refCount )` >t0> # |>| 3
t0 ' # 'm |>|
(
4
5
8
)
R0 ,/ |>| 4 5 8
R0 +/ |>| 17
' R0
always contains the result of the last computation .
Probably in those few lines a dozen lists were created and freed .
Compare the
s" Hello World "
in CoSy vs Python at
http://www.cosy.com/CoSy/#Videos .
Now let me see you duplicate the CoSy demo in raw Forth .