[mercury-users] How to transform `semidet' to `det' ?

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jul 25 18:11:29 AEST 2001


On 25-Jul-2001, David Overton <dmo at cs.mu.OZ.AU> wrote:
> On Wed, Jul 25, 2001 at 08:23:11AM +0200, Holger Krug wrote:
> > 
> > :- type rule_num
> >         --->    rule0x1
> >         ;       rule0x2
> >         ;       rule0x3
> >         ;       rule0x4
> >         ;       rule0x5
> >         ;       rule0x6
> >         ;       rule0x7
> >         ;       rule0x8
> >         .
...
> > * Is there any runtime performance overhead linked with my modifications?
> >   (Obviously there is a compile time performance overhead, because the
> >   new types could be really enormous discriminated unions.) Will there
> >   be any runtime performance overhead in future versions of the Mercury
> >   compiler? (The question, in short, is: Is the current or a future version
> >   of the Mercury compiler able to translate the enumerations `rule_num'
> >   resp. `state_num' as `int'?)
> 
> Enumeration types are represented as integers so there will be no
> runtime performance overhead.

Actually this is not completely true.  There is a small space overhead for
storing the run-time type information (RTTI) for this type, which is
used in case you call io__print, io__read, std_util__deconstruct, etc.,
on values of that type.  This small space overhead will decrease locality
slightly, which as usual may cause a minor slowdown due to increased
cache misses or paging.  The effect is very small, but it's there.

If you use --split-c-files, the compiler may be able to optimize this away in
some cases, but generally not if the enumeration type is used in a polymorphic
context (e.g. as the argument to a polymorphically typed procedure).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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