[mercury-users] abstract types.

Thomas Conway conway at cs.mu.OZ.AU
Wed Jan 19 10:34:51 AEDT 2000


On Tue, Jan 18, 2000 at 09:04:38PM EST, Ralph Becket wrote:
> > There's a bit of a problem in making bidirectional functions 
> > like this -
> > apart from anything else, the code for \/ing the bits together doesn't
> > work in the backwards mode (ie:
> > 	lr1item(ProdNum, Dot, Sym) = Bits :-
> > 		encode_sym(Sym, SymNum),
> > 		Bits = (ProdNum << 20) \/ (Dot << 12) \/ SymNum.
> > )
> > 
> > Now, you can work around this by using the C interface as a layer
> > between the layers of Mercury - implement the two modes as 
> > pragma c_code
> > that calls two separate mercury preds/funcs that each 
> > implement a single
> > mode. This seems expensive and ugly. Perhaps it's time to 
> > allow separate
> > implementations of different modes of a pred/func?
> 
> I agree that a facility for the latter would be useful.
> However, is it necessary for your code to use the same
> predicate for packing and unpacking?

It would be nice to be able to replace the functor lr1item/3 which
is used both for constructing and deconstructing LR(1) items with
a function lr1item/3 which does exactly the same job. That way the
interface to LR(1) items stays the same, but I can vary the representation.

-- 
 Thomas Conway )O+     Every sword has two edges.
     Mercurian            <conway at cs.mu.oz.au>
--------------------------------------------------------------------------
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