[m-dev.] for review: counter.m
Mark Anthony BROWN
dougl at cs.mu.OZ.AU
Fri Mar 10 12:42:00 AEDT 2000
Zoltan Somogyi writes:
> +
> +:- type counter.
> +
> + % counter_init(N, Counter) returns a counter whose first allocation
> + % will be the integer N.
> +:- pred counter__init(int::in, counter::out) is det.
> +
> + % counter__allocate(N, Counter0, Counter) takes a counter, and
> + % returns (a) the next integer to be allocated from that counter,
> + % and (b) the updated state of the counter.
> +:- pred counter__allocate(int::out, counter::in, counter::out) is det.
> +
Is it worth changing the type to
:- type counter(T).
and using the type parameter for some extra type safety, similarly
to what is done in varset.m? This would allow users to ensure that
a counter initialized for one purpose is not accidentally used
for another purpose. The above counter could be defined as
:- type counter == counter(generic).
for some suitable type `generic'.
Cheers,
Mark.
--
Mark Brown, PhD student )O+ | "Another of Fortran's breakthroughs
(m.brown at cs.mu.oz.au) | was the GOTO statement, which was...
Dept. of Computer Science and Software | uniquely simple and understandable"
Engineering, University of Melbourne | -- IEEE, 1994
--------------------------------------------------------------------------
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