[m-rev.] for review: direct argument functor type representation

Peter Wang novalazy at gmail.com
Tue May 31 12:40:59 AEST 2011

On 2011-05-26, Peter Wang <novalazy at gmail.com> wrote:
> Branches: main
> Implement a type representation optimisation ("direct argument functors"),
> where a functor with exactly one argument can be represented by a tagged
> pointer to the argument value, which itself does not require the tag bits,
> e.g.
> 	:- type maybe_foo ---> yes(foo) ; no.
> 	:- type foo       ---> foo(int, int).  % aligned pointer
> To ensure that all modules which could construct or deconstruct the functor
> agree on the type representation, I had planned to automatically generate
> pragmas in .int files to notify importing modules about functors using
> the optimised representation:
> 	:- pragma direct_arg(maybe_foo/0, [yes/1]).

While working on the packed enumerations representation, I came across
the undocumented `where type_is_abstract_noncanonical' syntax for solver
types.  When an enumeration is abstract-exported, I use the following
syntax in the implementation section of the .int file to indicate the
number of bits required to represent the enumeration, without listing
the functors.

    :- type foo where type_is_abstract_enum(3).

I think the `where' block attached to the type is cleaner than a
separate pragma, so eventually I will change the `:- pragma direct_arg'
to something like:

    :- type maybe_foo
	--->	yes(foo)
	;	no
	where	direct_arg is [yes/1].

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