types and operators
Nathan Hawkins
utsl@one.net
Thu, 13 Jun 1996 10:59:04 -0400 (EDT)
The following was written just before I left... Sorry about the long
delay, but maybe we can finish this subject, and get some code going.
I did do a little research into Lisp implementations, and I'm starting to
favour option 2 (see below), but as I recall, at the time I wrote this
(about a month ago) I was for method 2.
----------
This is a summary of the possible designs for implementing pointer/int
distinctions, along with pros and cons. If I've left out anything important
out, please let me know.
1. a small tag within a 32-bit int/pointer
Pros:
* probably comes closest to normal Forth
* a cell on the stack is the same as a cell on the heap
Cons:
* loses bits from every pointer and int :-(
* requires overhead in operators
2. Lisp-style cells, a pointer w/tag, and a 32-bit data element
Pros:
* hl things would be easy to implement
* doesn't lose any bits from pointers and ints :-)
* don't need to worry much about fragmenting the heap
* the stack could be implemented as a list on the heap
Cons:
* costs twice as much memory for each cell
* probably quite inefficient
3. traditional Forth, with a conservative collector
Pros:
* would be _very_ easy to implement
Cons:
* conserative collector - need I say more?
4. stack frames, with types tagged in the frame
Pros:
* supposedly would allow easier identifying of types on the stack
Cons:
* needs type tags copied into the heap separately
* breaks Forth concepts entirely
Of these, I think 1 and 2 are our best bets.
*utsl*