[m-rev.] structure flattening
Mark Brown
mark at csse.unimelb.edu.au
Mon May 2 23:45:36 AEST 2011
On 02-May-2011, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> On 02-May-2011, Peter Wang <novalazy at gmail.com> wrote:
> > This could only work if foo and bar are known, and whose representations
> > don't require the tag bits now used for variant.
>
> Basically, you probably want to do it if (a) each argument type is a type
> with only one alternative that uses the single_functor_tag, and (b) the number
> of alternatives in the top level type does not exceed the number allowed
> by the available number of tag bits (4 or 8).
>
> > I have doubts that the gains would be enough to justify the effort,
>
> The effort should be no more than a week, but I share your doubt.
> Does Michael have a convincing application?
One application that may be common is if you export a record-like
structure such as
:- type foo ---> foo(a, b, c).
from a module, and implement some sort of table that contains optional
foo records. You may use something like
:- type maybe_foo
---> yes_foo(foo)
; no_foo.
in the table implementation. In this case, the optimization would give
you a smaller table with faster lookups.
Note that flattening by hand would force you to export the no_foo functor,
which is likely to be inconvenient to users of the module.
Cheers,
Mark.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list