[mercury-users] Flattening (was: maybe(T))

Ralph Becket rafe at cs.mu.OZ.AU
Mon Oct 21 16:43:41 AEST 2002


Michael Day, Monday, 21 October 2002:
> 
> Well, looks like the idea I've been ineffectually groping towards is 
> really a type flattening optimisation that could be applied in specific 
> cases. I've noticed the following comment in the library:
> 
> % This "fat list" representation is more efficient than a list of pairs.
> 
> And the same sentiment seems to apply to the use of maybe(T) and other
> small convenience types generally. This kind of flattening can always be
> applied by hand, it just requires a lot of bulky code.

This sort of thing is done automatically by the MLj compiler, I believe,
although MLj is a whole-program compiler and therefore doesn't address
the problems that such an approach would lead to with separate
compilation.

> I get the feeling though that type flattening would require marshalling
> whenever the flattened structure had to be passed to a predicate expecting
> the generic one though, which would probably kill any benefits, or at
> least make it very difficult to identify when the optimisation would be
> beneficial.

When it works, it tends to work very well.  But as with most
optimizations, you always run the risk of hitting that "impedance
mismatch" and snarling things up.

- Ralph
--------------------------------------------------------------------------
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