[m-dev.] For review: Add implementation of reference types (global heap)
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Jun 9 14:37:22 AEST 1998
On 09-Jun-1998, Warwick Harvey <wharvey at cs.monash.edu.au> wrote:
> Fergus writes:
> > > extras/references/nb_reference.m:
> > > Implements references which are not backtracked on failure.
> > >
> > > extras/references/reference.m:
> > > Implements references which *are* backtracked on failure.
> >
> > In other parts of the Mercury library/extras, the convention has
> > been to use `foo.m' for the non-trailed version and `tr_foo.m'
> > for the trailed version. (Specifically library/array.m
> > and extras/trailed_update/tr_array.m, and library/store.m and
> > extras/trailed_update/tr_store.m.)
> > I think it would be good to adopt a consistent convention.
>
> But they're not quite the same thing are they?
Now that you point it out, no, they are not quite the same.
The implementations are pretty similar (trailed and non-trailed versions),
but the interfaces are different.
> With array/tr_array and
> store/tr_store, the two versions give the same result after backtracking, do
> they not?
"Mu". With array or store, unique modes are used to forbid you
from accessing the result after backtracking.
> Here, they are explicitly different: with one, changes are *not*
> undone on backtracking.
With array and store, the changes are also not undone on backtracking.
The difference is that with array and store, the interface
uses unique modes to prevent you from inspecting the changes
after backtracking.
I still think there's a fairly strong analogy between
nb_reference/reference and store/tr_store.
But maybe it's not compelling. So I'll leave this one up to you.
> > Our standard naming convention for type names in C is to use
> > "MixedCaseIdentifiers". So this should be `ScopeHandle'
> > rather than `scope_handle'.
>
> MixedCaseIdentifiers like MR_untrail_reason? ;-)
Yeah, I noticed that. Please feel free to fix that one too ;-)
> > > :- pragma c_code(exit_scope(Handle::mdi), will_not_call_mercury, "
> > > exit_scope((scope_handle) Handle);
> > > ").
> >
> > I suggest you use `pragma import' here:
> >
> > :- pragma import(exit_scope(mdi), will_not_call_mercury, "exit_scope").
>
> Is this documented anywhere?
No, not yet.
(I haven't documented it because Zoltan said he would.
I think he's still planning on doing that, he's just been
busy with other stuff.)
> How about I just put the body of ME_exit_scope() into the pragma c_code/3,
> like I did with enter_scope (which was so the heap pointer wouldn't be
> screwed up by the function call)?
That would be fine.
--
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 developers
mailing list