[mercury-users] Thanks for help: suggest small addition to lang.ref.
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed May 27 07:29:12 AEST 1998
On 26-May-1998, tcklnbrg <at at ingenuity-sw.com> wrote:
> I think that the above explanation would be a valuable addition to the
> language reference in the section on types. It would certainly clarify
> the use of the word constructor.
Ah, now I see why you were confused. Yes, "constructors"
in Mercury are quite different to "constructors" in Java or C++.
Mercury constructors are more like structs and/or enum constants in C.
If you want something like a C++ constructor, then you should
use a Mercury function (or predicate) to create instances of your
data type; you can use the module system to encapsulate the data type
and to ensure that instances of that type are only created via those
function(s) and predicate(s) that you specify in the module interface.
We'll see what we can do to clarify this in the reference manual.
By the way, the next major release of Mercury will probably support
nested modules, which can be useful if you want units of encapsulation
smaller than a single source file.
> [Thomas Conway wrote:]
> > Maybe we should take this discussion off mercury-users?
>
> I think I will need some advice on using
> Mercury's IO---the "no side effects" stuff.
>
> Where should I post my questions?
I think mercury-users is the right place.
--
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.
More information about the users
mailing list