[mercury-users] Visual Programming

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Nov 2 15:23:56 AEDT 1999


On 01-Nov-1999, Ralph Becket <rbeck at microsoft.com> wrote:
> As for expressing relations between N variables, what you'd like to be
> able to write is something like the following:
> 
> e.g.
> 
> 	% Speed = Displacement/Time
> :- pred sdt(float, float, float).
> :- mode sdt(out, in, in) is det.
> :- mode sdt(in, out, in) is det.
> :- mode sdt(in, in, out) is det.
> 
> sdt(Speed, Disp, Time) :- Speed = Disp / Time.
> 
> and get the right answer for the third, given any two arguments.  However,
> unfortunately life isn't that simple.  In the first place, things like
> rounding errors etc. mean that you won't get properly functional results.

True.

There is of course the `rational' type in the standard library which
computes arbitrary-precision rational numbers.

> In the second place, the compiler needs to know that * and / are duals,

I think the compiler already knows that.  The `float' module in the
standard library has mode declarations for `*' and `/' that allow them
to be used in reverse modes.  (Whether these actually make sense, given
the problems with e.g. rounding errors, is another question.  But
for cases where you just want a very simple kind of constraint solving
and where limited precision is acceptable, the reverse modes may be quite
useful.)

There's also the `cfloat' module in extras/clpr in the mercury-extras
distribution, which is an interface to the CLP(R) constraint solver.
That supports more complicated constraint solving, including linear
constraints, delayed non-linear constraints, and dynamic moding.

Currently the `rational' module does not support the reverse modes.
And we don't yet have any CLP(Q) (constraint solving on rationals).
But it would be possible to add them.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- 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