types and operators

Captain Napalm spc@armigeron.com
Sat, 27 Apr 1996 05:54:10 -0400 (EDT)


A long long time ago on a network far far away, Eric W. Biederman thus said:
> 
>       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.
> 
> Operations for pointers seperate from those for integers, will
> probably save us in the long run, as pointers sometimes take on the
> stranges formats.  A lot of the pointer + index work can be relaxed
> because a tidy house only needs to be presented at function call time.
> In addition for large objects that pointer would ususally step through
> recording where the object starts and have the garbage collector look
> it up, shouldn't be a problem.
> 
  At the least, you need:

	ptr + ptr --> ptr
	ptr + int --> ptr

> I have figured out how to do type-safe operators (compile-time
> type-safe) and identification of all pointers at run-time with no run
> time cost.  What it does require though is a restriction on how words
> can manipulate the data stack.   That is words must have a fixed
> number of arguments and a fixed number of results. 
> 
  I'm not sure if I can live with that.  I like having a variable number of
arguments, and a variable number of results (again, my Assembly days are
showing through).

  There is a way around this though, by the use of pointers (to arguments
and results), but that can be hidden.

> The reason I make the above restriction is as follows.  If words are
> to use a single stack as C does they can be implemented as allocating
> frames upon the stack.  The frame holding the funcions arguments, it's
> return locate, the address of the last words frame, the local
> variables, a buffer to receive results from functions, and most
> important a tag that tells what everthing is in the frame.  
> 
  What's wrong with the following scenario:

	Call a variable argument function (in a C like environment):

		printformat("time: %t date: %D\n",time(),date());

	And behind the scenes (still in a C like environment, but pretend
	it's at a lower level), you get:

	pfa         = frame(3);	/* number of arguments */
	pfr	    = frame(2); /* number of results   */
	pfa.arg[1]  = "time: %t date: %D\n";
	pfa.arg[2]  = time();
	pfa.arg[3]  = date();
	__printtformat(pfa,pfr);

  Assignments will carry along any type information (okay, so the above is
still a bit high level 8-)  Each function will have a fixed number of
arguments (in the case of printformat(), internally, two) and a fixed number
of results (in the case of printformat(), internally, none).

  -spc (just tossing out some ideas ... )