[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Apr 21 12:57:25 1993 
Subject:Stack Citizenship 
From: Robin Popplestone  
Volume-ID:930421.02 

Steve Knight in <116670075@otter.hpl.hp.com> and Aaron Sloman discuss the
problems associated with the  open stack. Certainly my experience (quite a
long one) is that it is one of the more troublesome features, but not in
the same league as "Segmentation Error - Core Dumped" that the users of
some languages are accustomed to. Sometimes one is left with a program that
is error free apart from accumulating things on the stack.

Some time ago I looked into the possibility of type-checking POP. With some
restrictions, it could be done by regarding each function as *parsing* the
stack when it uses its arguments, and *generating* a result. The implied
operations on grammars (effectively a kind of division operation) are well
understood by theorists, and are of an awkwardly high complexity in theory.
But don't let us forget that so is ML type inference. I did do a trial
implementation, which worked OK for some tricky cases (e.g. a while loop
that built things up on the stack). A grammatical might also give quite a
nice way of characterising structures like lists in more detail than a
conventional type-system could.

Certain constructions cannot be handled  in this way, e.g. *computing*  the
number of arguments.  The stack-count  brackets could  however probably  be
recognised and  handled correctly,  so that  certain cases  of the  use  of
functions like consstring which take the number of arguments as their  last
parameters could  be  treated. (In  general  you really  are  into  program
verification, since  the  computed number  of  arguments could  arise  from
anywhere).

On the other hand, Rod Burstall's [% ... %] construction works nicely,
provided that <stackmark> is treated as a singleton type, disjoint from all
others.

Somebody who knows the theory of grammars might like to take this problem
up - it would be a nice combination of some theory with some nitty-gritty
implementation.

Theoretically, it seems to me that the open stack provides a very useful
capability, namely a cheap way of combining the results of a function using
a free-semigroup operation.


Robin