A brief addition to Aaron's posting which included some amazing details
about WonderPop.
>Moreover this extension might not go well with the existence of
>functions which can be applied to many types of objects, e.g. <> which
>can compose functions, can join two words, two strings, two vectors, two
>lists. Purists might which to add specialised versions of <>, i.e.
>word_<> string_<> vector_<> etc.
It is the issues of polymorphism, subtyping, and overloading that made
me hesitant to suggest a project to add types to Pop11. If I twist
my own arm and insist on suggesting a type system I would be inclined to
adopt a Java-like approach. In other words, types would be class
based (i.e. not polymorphic) and structured in a subtype hierarchy.
>And don't you like being able to treat lists as if they were functions,
>i.e. typing
> list(3)
>rather than
> hd(tl(tl(list)))
> ??
This isn't much of a problem, I reckon. Because we need a type system
suitable for object-oriented data types, we would have the means to
embrace -apply- as a method. In other words, the solution to the
bigger problem would solve this little problem.
>But some will complain that run time is too late: we need to find errors
>at compile time, before anyone runs the code in earnest.
But there is a weaker, pragmatic position that I would adopt. It is
very nice to be informed of some of your common mistakes at run-time.
I do not demand that a type system is perfect - just helpful. And
I do find it is helpful.
>Syssort is an example of an enormously useful higher order function. It
>was written on the assumption that there was no need for its author to
>think about the types of the elements of the lists or the types of the
>arguments of the predicate. That responsibility can be left to the
>programmer who provides the ordering predicate, and if she wants the
>list to contain an arbitrary mixture of types of entities, that's fine,
>as long as the predicate supplied can handle any combination of them.
>
>I understand you can't do that in ML, despite its support for
>polymorphic types.
This is not quite right. Standard ML (as opposed to earlier versions)
is very picky about what types you can test for equality. It is this
issue that bites i.e. that equality is not a polymorphic function in
SML. They solve this through the somewhat overblown functor system.
>4. Although it would be hard to change pop-11 to behave like a language
>with strong static types (i.e. every expression has a well defined,
>reliably computed type), it might be both easy and very useful to extend
>the variable declaration syntax so that variables had types associated
>with them which are checked at *run* time. E.g.
Yes. It is exactly this approach which is being suggested, I believe.
To be honest, I would rather see a new subsystem added to Poplog which
was designed with this in mind, rather than trying to extend Pop11
as it is. Such a subsystem could be designed so that exporting
functions back into Pop11 was trivial - so it would be easy to write
Pop11 libraries in this new language which took advantage of snazzy
new features that would be tricky to integrate with Pop11.
[To that end, I would like to see a couple of improvements in the Poplog
VM. The first would be the ability to create a new, empty top level
section. The second would be an enhancement to the Poplog VM to
allow the word-oriented procedures (sysPOP, sysPUSH, sysCALL, sysUCALL
sysLOCAL) to take idents as well as words as arguments. The latter
request is a trivial modification to vm_plant.p, incidentally. I know
these requests are obscure but I thought I would jot them down anyway.]
Steve
|