[m-dev.] for review: tuples [1]

Peter Schachte schachte at cs.mu.OZ.AU
Wed Aug 2 13:32:58 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).

    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 only see one disadvantage:  for triples and above, the representation is
inefficient (and for pairs, the standard pair type is probably fine).  This
could be fixed by implementing structure inlining of single-constructor types.
Of course, this would have benefits in many other situations, as well.  Is
there some reason that this is a more difficult optimization than it would
seem?


-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  Abstraction is the only mental tool
http://www.cs.mu.oz.au/~schachte/      by means of which a very finite piece
Phone:  +61 3 8344 9166                of reasoning can covera myriad of
Fax:    +61 3 9348 1184                cases. -- Edsgar Dijkstra 
--------------------------------------------------------------------------
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