[mercury-users] Records

Juergen Stuber juergen at mpi-sb.mpg.de
Sat Nov 6 08:07:53 AEDT 1999


Fergus Henderson <fjh at cs.mu.OZ.AU> writes:

> On 05-Nov-1999, Juergen Stuber <juergen at mpi-sb.mpg.de> wrote:
> > Fergus Henderson <fjh at cs.mu.OZ.AU> writes:
> > > We definitely want to allow explicit type qualifiers in clauses.
> > > Currently the plan is for that to use the syntax `Expression : Type'.
> > > (There's already code in the compiler to handle this, but it's not yet
> > > enabled because `:' is currently used as module qualifier.)
> > > 
> > > We probably also want to allow different clauses for different modes of
> > > a predicate (perhaps with such predicates defaulting to `impure',
> > > requiring an explicit `pragma promise_pure' if the different modes have
> > > the same semantics); currently this is possible using the C interface,
> > > but it would be nice to have a more direct syntax for that.
> ...
> > > Now, if we combine both of those extensions, then you could write
> > > 
> > > 	foo(X : t) :- ...
> > > 
> > > and
> > > 
> > > 	foo(X :: m) :- ...
> > > 
> > > and they would mean quite different things.
> > > You could even use them both in the same clause:
> > > 
> > > 	foo(X : t :: m) :- ...
> > > 
> > > If `::' is to be used for both type and mode qualifiers,
> > > then that wouldn't work.
> > 
> > That depends on whether you can distinguish types from modes
> > or not.  Currently you cannot, because they have their own
> > namespaces and there is a fair amount of overloading.
> 
> Yes.  I think that is unlikely to change.
> Using the same name for a type and its corresponding
> inst is common, and IMHO often improves readability.
> 
> > BTW, will you also support such declarations in goals, or
> > only in heads as your example suggests?
> 
> Type qualifiers would definitely be allowed in goals.
> Mode qualifiers would probably only be allowed in heads.
> 
> > > But in recent development versions, we allow
> > > 
> > > 	Foo `qualifier__infix_op` Bar
> > > 
> > > and hence
> > > 
> > > 	Foo `'int__+'` Bar
> > > 
> > > Or of course you can use prefix:
> > > 
> > > 	'int__+'(Foo, Bar)
> > 
> > That will do nicely, thanks.
> > I tried it with rotd-1999-09-17 where it didn't yet work.
> 
> The feature was added in July, so it should work fine
> in rotd-1999-09-17.  It seems to work fine according
> to some simple tests I tried.  If it doesn't, please
> send us a bug report.

Last time I tried it I must have done something wrong,
for my simple tests now also indicate that it works.

FIM

Jürgen

-- 
Jürgen Stuber <juergen at mpi-sb.mpg.de>
http://www.mpi-sb.mpg.de/~juergen/
--------------------------------------------------------------------------
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