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

Holger Krug hkrug at rationalizer.com
Wed Jul 25 16:23:11 AEST 2001


I've added an option "--unique-state" to the moose parser generator to
allow values allowing only unique references (like those of type
io__state) to be used as parser_state. I'll post the changes of having
finished the necessary tests. I the course of modifying moose I
encountered the following problem:

I had to change the determinism of some of the moose procedures from
`semidet' to `det'. Those procedures originally where defined to work
on state and rule numbers of type `int'. Some of those state and rule
numbers where declared to be input parameters. Because there is only a
finite number of states and rules the original versions of the
procedures were `semidet'. To be able to declare them as `det' I generated
new type definitions like:

:- type rule_num
        --->    rule0x1
        ;       rule0x2
        ;       rule0x3
        ;       rule0x4
        ;       rule0x5
        ;       rule0x6
        ;       rule0x7
        ;       rule0x8
        .

:- type state_num
        --->     state0x0
        ;        state0x1
        ;        state0x2
        ;        state0x3
        ;        state0x4
        ;        state0x5
        ;        state0x6
        ;        state0x7
        ;        state0x8
        ;        state0x9
        ;        state0xa
.

The parameter types of the procedures in question I redeclared to 
be `rule_num' resp. `state_num'.

My questions now are:

* 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'?)
* Are there other ways to change the determinism of procedures from `semidet'
  to `det'? All procedures in question have input and output parameters and
  should work only on a sub-type of the declared input types.

-- 
Holger Krug
hkrug at rationalizer.com
--------------------------------------------------------------------------
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