[Types-sig] New syntax?

Evan Simpson evan@4-am.com
Mon, 20 Dec 1999 11:51:08 -0600


[Tim Peters wrote:]

> So let's make one up.  The problem is spelling "tuple of unknown length"
> (and Paul's complaint notwithstanding, that *is* Python so we gotta deal
> with it).  Python has no notation for this.

In one of the many messages I started composing for this SIG, then never sent,
I mixed regexp-style notation into your ML-style declarations.  How's about:

(T*) means T-tuple of unknown length, (T+) means length at least one, (T1?,
T2{1,2}, T3) means optional T1 followed by one or two T2's and exactly one T3.
This still requires (T,) for a single-T tuple, but all other uses are
distinguishable from grouping.

> Actually, tuples show up in type specifiers rarely enough-- and look so much
> like grouping now --that I'd be happy requiring "Tuple" all the time.  Again
> one of those things that could be relaxed later if it proved too irksome.

Naturally, this isn't restricted to tuples;  Argument (and regular) lists could
also use it.
In particular, the much-discussed range could be declared as:

decl def range(start as Int?, stop as Int, step as Int?) return [Int*]

(and I still think "default" arguments used for closures should be separable
from regular arguments by a ';', but that's another SIG)

Still can't spell 'map', though.

decl def(ResultType, *SeqTypes) map(def(SeqTypes) return ResultType, map(lambda
x: Sequence(x), SeqTypes) )
    return [Result{len(SeqTypes)}]

<bleagh!>

Cheers,

Evan @ 4-am