[mercury-users] tuple syntax

Peter Schachte schachte at cs.mu.OZ.AU
Wed Nov 10 23:18:53 AEDT 1999


On Wed, Nov 10, 1999 at 10:27:52PM +1100, Peter Schachte wrote:
> (This would be a lot nicer if Mercury had a decent syntax for
> tuples, but let's just worry about one syntax hack at a time.)

Hmmm.  Here's an idea for a better tuple syntax.  Is there something
wrong with this?  If not, it might be a nice easy addition to the
standard library somewhere.

	 :- type (A,B) ---> (A,B).

Not a lot to it.  But it would allow you to declare, eg, a list of
<name,age,weight> tuples as list((string,int,float)), and then
(de)construct such a list as [(Name,Age,Weight)|Rest].  Of course, the
parentheses are required.

Perhaps it would a bit nicer to surround tuples with angle brackets,
and there's some danger of users coming to grief by forgetting the
parentheses, but this generalizes to n-tuples pretty well (I don't
think pair/2 does), and looks reasonably good.  Most importantly, it
works now.


-- 
Peter Schachte                     [A computer is] like an Old Testament
mailto:schachte at cs.mu.OZ.AU        god, with a lot of rules and no mercy.
http://www.cs.mu.oz.au/~schachte/      -- Joseph Campbell 
PGP: finger schachte at 128.250.37.3  
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list