[mercury-users] Exceptions and unique modes

Peter Schachte schachte at cs.mu.OZ.AU
Fri Feb 23 11:11:56 AEDT 2001


On Fri, Feb 23, 2001 at 10:05:08AM +1100, Thomas Conway wrote:
> On Thu, Feb 22, 2001 at 10:45:32PM EST, Ralph Becket wrote:
> > >From Peter Ross on 22/02/2001 11:41:32

> > > :- type t
> > >     --->    f(int)
> > >     ;       g(int, int).
> > > 
> > > No matter what you initialise this type to you need to make sure that
> > > you allocate 2 words so that you can possibly hold the g constructor at
> > > some later date.

There are lots of ways to reuse memory.  One way would be to have a free
list for each size of structure.  when an f/1 term becomes free, it is
placed on the chain of free 1-word free cells.  When a g/2 term needs to be
allocated, it is taken from the 2-word free list.  Unless it's mostly the
case that when replacing an f/1 term with a g/2 term the first argument is
usually the same, I can't see how there'd be much benefit to allocating 2
words for every f/1 term just so you can convert between them in place.

> That's all well and good for the type `t' above, but for 234 trees
> it is less clear whether this is a good idea:

[Then Tom goes on to show that it may very well be worthwhile to allocate 4
words for every tree234 term....]

Perhaps when structure reuse could make use of it, there should be a pragma
that allows users to indicate for which DU types all terms should be
allocated the same space so the compiler can morph among them.

-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  I think their attitude right now is
http://www.cs.mu.oz.au/~schachte/      that, because [Microsoft are] a
Phone:  +61 3 8344 9166                computer company, ... they're beyond
Fax:    +61 3 9348 1184                quality control. -- Harvey Levine 
--------------------------------------------------------------------------
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