[mercury-users] Visual Programming

Ralph Becket rbeck at microsoft.com
Mon Nov 1 23:43:02 AEDT 1999


Hi,

if you're intersted in graphical/graph based languages I suggest you
search around for stuff on Interaction Nets (you'll probably find it
immersed in stuff about linear intuitionistic logic, which you may
prefer to skim until you get the hang of IN.)  I wrote a compiler
for this language in Modula 3 many years ago.  It's very simple and
has lots of nice properties.  It also has a lot of practical problems:
how do you neatly lay out graphical programs?  How do you debug them
(many graph based languages can have several redexes on the go at once)?
Etc.

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.
In the second place, the compiler needs to know that * and / are duals,
which is harder to express.  Work is going on to help you express properties
like this to the compiler:

:- promise all [A,B,C] (A = B/C <=> B = A * C).

but it'll be a while yet (if ever) before the compiler can take advantage of
this declaration.  Currently, AFAIK, the compiler only understands
particular
ways of declaring certain binary operations to be commutative or
associative.

> In my opinion, the 'promises' of commutativity (axioms, I 
> guess) which were
> mentioned recently are really just an artifact of an 
> inexpressive notation
> - in fact, addition and multiplication each operate on a bag 
> of numbers,
> and bags aren't ordered, so commutativity is implicit.

Au contraire!  Place-value notation is very important.  For example, it's
important to get the order right when concatenating strings; of course, you
don't really care when you're adding floats or ints.  If you don't have
place-value, you're really stuck.

Cheers,

Ralph
--------------------------------------------------------------------------
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