[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Apr 10 21:15:35 2000 
Subject:Re: List of Possible Poplog Projects 
From:pop 
Volume-ID:1000410.09 

Chris Dollin said:

> OO-style inheritance doesn't cut it. C++-style templates are a bad
> approximation to ML-style polymorphism. Java-style distinctions between
> primitive types" and "class types" just serve to complicate that
> which was already simple.

Actually, I'd say that Java makes a sensible decision to distinguish
statically between what's necessarily a pointer and what's definitely not.
This provides information necessary for garbage-collection while preserving
the natural operations of the machine on non-pointer entities. Given that
machine architectures don't support tagging, I'd say that Java's made the
right decision.

> Pop's type system is currently used in far too rich a way for the "usual"
> static type systems to capture enough of it for practical purposes.

> [I've played around with this before, and I know that Robin has too. It's
>non-trivial. *Deeply* non-trivial.]

If a static type system is not to restrict our freedom it's got to be
trivial or unsound or undecidable. POP has in effect a near trivial type
system (the procedure restriction on variables is the only thing that makes
it non-trivial). C and C++ have unsound type-systems, which certainly find
trivial bugs, but which admit major non-trivial bugs. The soundness
of POP's trivial type system is compromised by the fast_  options. [By
POP's type system being sound I mean that the value of every expression
should be correctly handled by the garbage collector].

If we wanted to make a static type system that let us have a lot of
the freedoms to which we have become accustomed we'd have to  deal

    (a) with union types
    (b) with the open stack

We can approach (a) by adopting a type-system that replaces the system
of type-equations on which Hindley-Milner type inference is based by a
system of type-inequalities. This has been done for Scheme I believe and
for Erlang (by Wadler et al.) It's tricky.

The approach to (b) is to recognise that what a function operating
on the open stack does is to take a sequence of values off the
stack and put another sequence of values back on. So the concept
of type has to be that of sets of sequences. What is a set of
sequences? Well, it's a language, which we might specify with a
grammar. So we could get a type-system for POP by regarding a
function as parsing the stack for something recognised by its
argument-grammar and generating something from its result grammar.
The type of a function is then characterised by a quotient grammar.
If the grammars are regular, taking the quotient of grammars
is decidable. Of course requiring that these grammars be regular is an
infringement on the liberty of the POP-hacker, but not so grave an
infringement that he or she might not thole it. Except of course that we
have a non-grammatical convention for some uses of the open stack - putting
a count on top, as in consstring.


Robin.