[mercury-users] tuple syntax
David Glen JEFFERY
dgj at cs.mu.OZ.AU
Thu Nov 11 13:10:57 AEDT 1999
On 10-Nov-1999, Robert Ernst Johann JESCHOFNIK <rejj at cat.cs.mu.OZ.AU> wrote:
> > 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).
>
>
> I asked DJ this exact question a few weeks ago. I cannot remember exactly
> what he said, but I remember that there was a reason pair was defined like
> it is. I think it may have been a precedence problem. DJ?
I think my comment was that you *could* do that, and it would work, but the
representation the compiler would use for n-tuples when n gets big wouldn't
be terribly efficient.
eg. a five-tuple: (1,2,3,4,5) wouldn't be represented by five cells on the
heap; each instance of the ','/2 functor effectively takes an extra cell,
giving a total of nine (probably).
It would (in many cases) be much more efficient to represent five tuples by:
:- type fivetuple(A, B, C, D, E) ---> fivetuple(A, B, C, D, E).
In this case you would avoid the overhead of all the pointers between the
','/2 blocks... the representation of a fivetuple/2 would actually fit into
five cells.
Anyhow, this may not be an important consideration for many applications, and
we could probably do a good job of optimising the representation if we tried.
HTH.
dgj
--
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student, | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.| With sufficient formality
The University of Melbourne | The sheerist banality
Australia | Will be hailed by the critics: "Miraculous!"
| -- Anon.
--------------------------------------------------------------------------
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