types and operators

Nathan Hawkins utsl@one.net
Tue, 23 Apr 1996 17:50:13 -0400 (EDT)



On Tue, 23 Apr 1996, Eric W. Biederman wrote:
> Now all we have to do is figure out is what kinds of data types and
> which opeations on them, our lll will support.

I. Data types we will _need_
   A. integers
      I'd prefer integers to be based on 32-bit or greater. (16-bit isn't 
worth messing with, IMHO.) We need arithmatic, logic, comparison, etc. 
All of which will have to work with whatever munging we do to the 
integers to distinguish them from pointers, so I'd like to be able to do 
that in 1 or 2 instructions, if possible.

   B. pointers
      Pointers will need some basic operations, and some design decisions 
will have to go into dealing with pointers into objects vs. pointer+offset. 
We'll need operators to access all the supported types through pointers, 
with indexing.

   C. strings
      I favour using counted strings, and providing a good set of 
operators to work on them. We will need to mark strings so that the 
garbage collector knows to leave them alone.

II. Optional types
    A. buffers
       Buffers are very close to strings, but might concievably need 
different treatment. Mostly, there will need to mark memory objects which 
the GC should not access, and operators that can access them.

    B. floating-point
       Floats would be a mess to do, especially when it comes to 
distinguishing them from integers, pointers and strings. This can 
probably be added later.

    C. double-length integers
       I'd like to have these from the start, if possible. Variations of 
the integer operators, and some conversion operators.



There will need to be some thought put into stack operations. I was 
planning on keeping the standard Forth ones. Any comments on this?

Also, I'd like to have a some ideas about how to do pointer/integer 
distinction with a minimal instruction count for operators. Since + - * / 
etc. will all have to convert LLL integer --> machine integer 
conversion and back, I'd like it to be kept to something we can do with a 
minimal instruction count.

Finally, a question of operator behaviour: should operators be type-safe, 
or should they just produce undefined results? For instance: what happens 
when you add a pointer to an integer with the integer addition operator?
Also, if operators are type-safe, what should they do when given the 
wrong parameters? (Exception-handling?)

*utsl*