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

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jun 13 20:56:04 AEST 2011


On Tue, 31 May 2011, Peter Wang wrote:

> 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].

I agree.

Julien.
--------------------------------------------------------------------------
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