Extension: List Types

Example

void
printlist(list(char*) *strings)
{
  list(char*) *l;
  for(l=strings; l; l=l->tl)
    printf("%s\n", l->hd);
}

Syntax & Semantics

A list structure is defined as:

struct list {
  void *hd;
  struct list *tl;
};

The extension defines a new type specifier list(T) where T is any valid pointer type. The implementation of list(T) is equivalent to the struct list shown above, but if T and T1 are different types, then list(T) and list(T1) are treated as different types for the purposes of type checking.

Probably the extension should implement more generic parameterized types.

Implementation

Implemented by tinyrscc. Not implemented elsewhere.