[clean-list] Some problems with strict lists

John van Groningen johnvg@cs.kun.nl
Tue, 15 Jan 2002 18:00:57 +0100


Jerzy Karczmarczuk wrote:
>No problem with printing, etc.
>But I think that everybody would agree that people working with lists and
>saying: "Wonderful! I can now *really* optimize my program!" - and discovering
>subsequently that (++) doesn't work, map, length neither, nor even indexing -- 
>all because of type problems,
>they may become emotionally destabilized, as I was...
>
>Now.
>Of course I can define (and I did) some private functions which mangle [! !] or
>[# !] (although some discussion of the syntax in the report would help; I am
>not even sure about the syntax of the empty list...)

The syntax of empty lists is:
[]   // empty lazy list
[!]  // empty head strict list
[ !] // empty tail strict list
[!!] // empty head and tail strict list
[#]  // empty head strict and unboxed list
[#!] // empty head strict and unboxed, tail strict list
[|]  // the overloaded empty list

>but we risk to produce things not so compatible with what the Gurus are
>planning.
>
>Perhaps such functions as map, length etc. will be doubly overloaded, over the
>list constructors as well?
>
>Is there something to say here?

We have not yet decided how to support strict lists in the StdEnv. We first
need to use the strict lists in some large programs for a while. We haven't
even started with this yet.

I have created a StdOverloaded module, that contains overloaded versions
of all the functions in StdList. The names of these functions start with
an uppercase character, instead of a lowercase character. If such a function
uses more than one list, these lists must all have the same strictness and
unboxing properties. For example Reverse of a [# !] list, yields a [# !]
list. This was done to reduce problems with unresolveable overloading, and
to reduce the number of specialized versions.

StdOverloaded also defines macros for most functions in StdList, without
restricting the overloading of lists. The names of this macros also start
with an uppercase character, and end with an extra 'M'. For example
ReverseM can reverse an [# !] list and yield any kind of list, for
example [! ].

Functions that use higher order functions, are defined as macros instead,
to allow to compiler to specialize the function/macro, for example Map
and Filter.

The StdOverloaded.icl and StdOverloaded.dcl files can be downloaded at:

ftp://ftp.cs.kun.nl/pub/Clean/supported/StdStrictLists/

This is just a first attempt, it will probably change and may even disappear
completely.

Regards,
John van Groningen