[m-rev.] Version types for review
Ralph Becket
rafe at cs.mu.OZ.AU
Tue Sep 7 14:51:42 AEST 2004
Julien Fischer, Friday, 3 September 2004:
>
> On Fri, 3 Sep 2004, Ralph Becket wrote:
> > %
> > % A version store - this operates with similar efficiency to an ordinary
> > % store, but "older" versions of the store are still available, but work
> > % less efficiently as more updates are made to the "latest" version of
> > % the store. Operations on the "latest" version are always O(1).
>
> That paragraph could be expressed better.
Changed to
% A version_store is similar to, albeit slightly slower than, an ordinary
% store, but does not depend upon uniqueness.
%
% Note that, unlike ordinary stores, liveness of data is via the version store
% rather than the mutvars. This means that dead data (i.e. whose mutvar is
% out of scope) in a version_store may not be garbage collected.
> > % The advantage of version stores is that they are ordinary ground terms
> > % and can therefore be nested and so forth without the need for complicated
> > % insts.
> > %
> > %-----------------------------------------------------------------------------%
> This is one of the benefits of version structures in general. I think
> you should probably mention that in version_types.m as well.
Done.
> > % Construct a new version store. This is distinguised from other
> s/distinguised/distinguished/
Done.
> I don't think you need to keep saying that the predicate
> versions are suitable for use with state variables. State
> variables work with both versions - the predicate version
> is just a little more convenient. Our current coding
> standard suggest placing the declarations for both
> the predicate and function versions of the same operation
> under a common comment.
Done.
> > % unsafe_rewind(VS) produces a version of VS for which all accesses are
> > % O(1). Invoking this predicate renders VS and all later versions
> > % undefined that were derived by performing individual updates.
> That should probably say:
>
> Invoking this predicate renders VS and all later vsions that
> were derived by performing individual updates undefined.
I've changed it to "this predicate renders undefined VS and all later
versions..."
> > %-----------------------------------------------------------------------------%
> > % Copyright (C) 2001-2002 The University of Melbourne
> > % This file may only be copied under the terms of the GNU Library General
> > % Public License - see the file COPYING.LIB in the Mercury distribution.
> > % vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
> > %-----------------------------------------------------------------------------%
>
> 2002? Surely you've worked on it since then.
Fixed.
> > % set(BM, I), clear(BM, I) and flip(BM, I) set, clear and flip
> > % bit I in BM respectively. An exception is thrown if I is out
> > % of range.
> > %
> > :- func set(version_bitmap, int) = version_bitmap.
> >
> > :- func clear(version_bitmap, int) = version_bitmap.
> >
> > :- func flip(version_bitmap, int) = version_bitmap.
> >
> > % Versions of the above suitable for use with state variables.
> > %
> > :- pred set(int::in, version_bitmap::in, version_bitmap::out) is det.
> >
> > :- pred clear(int::in, version_bitmap::in, version_bitmap::out) is det.
> >
> > :- pred flip(int::in, version_bitmap::in, version_bitmap::out) is det.
> >
> As mentioned above it's probably better that the declarations for
> the predicate versions are grouped together with the function versions.
Done throughout.
> > % is_set(BM, I) and is_clear(BM, I) succeed iff bit I in BM
> > % is set or clear respectively.
> > %
> > :- pred is_set(version_bitmap, int).
> > :- mode is_set(in, in) is semidet.
> >
> > :- pred is_clear(version_bitmap, int).
> > :- mode is_clear(in, in) is semidet.
> >
> Is there any reason you haven't used predmode syntax here?
Fixed throughout.
> > :- func search(version_hash_table(K, V), K) = V is semidet.
> > :- pred search(version_hash_table(K, V)::in, K::in, V::out) is semidet.
> >
> > % Convert a hash table into an association list.
> > %
> > :- func to_assoc_list(version_hash_table(K, V)) = assoc_list(K, V).
> >
> It might also be worth providing a from_assoc_list function.
That's something to be added to hash_table.m as well. I'll put it on my
TODO list.
> > set(HT0, K, V) = HT :-
> >
> > % If this is the first entry in the hash table, then we use it to
> > % set up the hash table (the version_arrays are currently empty because
> > % we need values to initialise them with).
> > %
>
> Fix the indentation there (assuming that it's not cvs or my mail reader
> doing that).
Fixed.
> More later.
Ta!
-- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list