[m-dev.] for review: tuples [1]
Simon Taylor
stayl at cs.mu.OZ.AU
Sun Aug 6 14:36:59 AEST 2000
> On Wed, Aug 02, 2000 at 12:00:38PM +1000, Fergus Henderson wrote:
> > One possibility would be to add list-like features for tuples.
> > The type `{ T1 | T2 }' could denote a tuple type whose first
> > element has type T1 and whose remainder has type T2 (which must
> > be a tuple type).
>
> Hang on. If you're going to do that, wouldn't you be a lot better off using
> the defn:
>
> :- type (T1,T2) ---> (T1,T2)
>
> This has several advantages over the {...} notation:
>
> 1) No need to introduce Fergus' {T1 | T2} notation: (T1,T2) covers it
>
> 2) Much more orthodox notation mathematically (Using parentheses for
> tuples is only a little less common than angle brackets; they're
> certainly a *lot* more orthodox than braces).
Not using parentheses was a deliberate decision so that unary tuples work
when passed to a predicate which takes a polymorphic argument which is
expected to be a tuple of any arity. If unary tuples don't work, then the
arity needs to be passed separately so that the unary case can be handled
as a special case.
> 3) Doesn't take away the orthodox notation for sets. It would be nice to
> reserve braces for sets at some later time.
I can't see this being useful. list_to_set([1, 2, 3]) is not that
much worse than {1, 2, 3}.
Simon.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list