[mercury-users] Mercury needs a Tutorial

Peter Schachte schachte at cs.mu.OZ.AU
Fri Feb 12 16:32:51 AEDT 1999


On Thu, Feb 11, 1999 at 09:47:53PM +1100, Fergus Henderson wrote:
> One thing I have considered doing is extending the language to provide
> special syntax for queries, as an alternative to defining main/2.

We talked about this once (I had asked for exactly this) and you
pointed out that there had to be a way to get ahold of the input
io__state, and return the final one at the end.  At the time, we
couldn't think of anything very syntactically elegant.  Have you
worked out a reasonable syntax for that?  A headless DCG clause,
maybe?  Anyway, if you've got a reasonably pleasing syntax, I think
this would be a good idea.

While you're doing this, it would be worth also considering adding
initialization goals.  I don't have a syntax proposal, but it would
want to be like specifying a main, except that all initializations
would be executed, in some unspecified order, before the main is
executed, and the input io__state of the first initialization would be
real initial io__state, the input io__state for each other
initialization would the output io__state of the previous one, and the
input io__state of the main would be the output io__state of the final
initialization.  When you need this facility, it's very unpleasant to
try to do without it.

Another thing to consider is that it's sometimes convenient to have
several mains in a single program, and have the concept of a "main"
source file for a project which determines which module's main to use.
Then the various subcomponents of a large project can each have its
own main so they can be run stand-alone, and still have an integrated
driver module that links in all the component modules and has its own
main to drive them.  With the current scheme, for every component foo
you'd have to have a separate module foo_main.m containing just a
main/2 that just calls foo/2.  Not a big deal, but a bit of a nuisance
which you might as well fix if you can.

-- 
Peter Schachte                     In a democratic time culture, everyone's
mailto:schachte at cs.mu.OZ.AU        time is valueable and no one's time is
http://www.cs.mu.oz.au/~schachte/  any more expendable than another's.
PGP: finger schachte at 128.250.37.3      -- Jeremy Rifkin 



More information about the users mailing list