[m-dev.] for review: counter.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Mar 10 20:08:04 AEDT 2000
On 10-Mar-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> > > + % counter_init(N, Counter) returns a counter whose first allocation
> > > + % will be the integer N.
> > > +:- pred counter__init(int::in, counter::out) is det.
> >
> > It would probably be better to make that a function rather than
> > a predicate. Or alternatively, if you want consistency with the
> > rest of the library, you could define both.
>
> The allocate predicate cannot usefully be made into a function, since it
> returns two items. As long as that is the case, making counter__init into
> a function would not feel right.
Doesn't the same argument apply to e.g. queue__init and queue__get?
Yet we have a function version of queue__init.
Likewise stack__init and stack__pop, set__init and set__remove_least,
array__init and array__bounds, and for dozens of other *__init
functions in the standard library.
So I'm not convinced by your argument.
If it's consistency you're looking for, then we should do
the same as with the other library modules. And I can't
see any other argument for making counter__init a predicate
other than consistency.
To me making counter__init a predicate doesn't feel right,
since it forces some code using it to be needlessly verbose.
--
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-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list