[mercury-users] query

Peter Moulder pmoulder at mail.csse.monash.edu.au
Tue Mar 18 14:32:07 AEDT 2003


On Tue, Mar 18, 2003 at 01:16:52PM +1100, Ralph Becket wrote:
> Peter Moulder, Tuesday, 18 March 2003:
> > 
> > For a version that works with older versions of Mercury, replace the
> > `main' line above with:
> > 
> > main(S0, S) :- io__write_string("Hello, World!\n", S0, S).
> 
> The code in the book only has to work with the latest official release.
> I'd rather use state variables here because the reader only has to
> understand "ah, !IO means IO is performed."  Naming IO states explicitly
> is really going to turn off a lot of readers before they've finished the
> first chapter.

Oh, I agree with that, what should go in the tutorial I mean;
I was just giving additional information for readers of mercury-users
that aren't using ROTD versions of Mercury.

State variables (and field access functions) are a big win.  Using dot
`.' as a module qualifier is a win, but not as much.  Given that it
doesn't work in the current latest official release (0.11), I think 
we should try to avoid it in examples posted to mercury-users.

Actually, in this example, the module qualification is redundant.
Mercury programmers have a strong tendency to use module qualification
for some things, but I don't know how much that's just habit from the
days when it was mandatory.  Is there really any ambiguity as to the
meaning of unqualified `write_string' ?  I'm less comfortable with
`state'; but on the other hand, io__state represents more than just I/O
state: it can be used for stores or other memory state (e.g. when
interfacing with foreign code), so one might even consider it an
advantage not to mention the io qualifier for state types.

(Ah, I've only just noticed that io__io has been added as a synonym for
io__state, which is why the `pred(io, io)' used in the posted example
works.)

Whether the tutorial should use dot or `__' or unqualified names depends
in part on when the next official release (a release supporting dot as
module qualifier) will be released.

I'd be interested in trying unqualified names in the tutorial as an
experiment.  I know I often consciously use redundant module qualifiers
in my code, but it would be interesting to see if new users would come
to that decision even if all the tutorial code used unqualified names.

pjm.
--------------------------------------------------------------------------
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