[m-dev.] tabling, trailing and impure references
Zoltan Somogyi
zs at cs.mu.OZ.AU
Tue Aug 12 18:29:20 AEST 2003
On 12-Aug-2003, David Overton <dmo at cs.mu.OZ.AU> wrote:
> > Thanks. However, the part of that sentence from the reference manual
> > which I left out ("... or if you select a garbage collection method
> > other than the default (conservative) ...") seems to apply to
> > `:- pragma memo' tabling as well. In particular, if I compile the
> > example I gave in grade asm_fast.tr I get a runtime error:
> >
> > Mercury runtime: Cannot copy a c_pointer type
> >
> > Is there any chance of getting `:- pragma memo' working in non-gc
> > grades? (We only need it for benchmarking purposes, but it would be
> > useful, nonetheless, if it's possible.)
>
> I didn't get a reply to this.
I wanted to talk to you in person, because the above mail seems to be based
on a misconception.
> Can anyone tell me what would be involved
> in getting `:- pragma memo' to work in non-gc grades, at least for
> nullary functions?
Pragma memo *should* work in non-gc grades, though I can't test it right now
because by default the libraries aren't installed in non-gc grades.
Tabling of any kind doesn't work on c_pointers. This is a deliberate decision,
and is required for soundness: the fact that a C pointer has the same value at
two different times (e.g. when it is entered into a call table and when it is
looked up in that call table) doesn't guarantee that the data structure it is
pointing to has the same value at those times. Given that Mercury doesn't know
what a C pointer is pointing to, it cannot take the chance.
However, the programmer could assert that two pointers being equal implies
that the data structures they point to are equal. I introduced the
type_ctor_rep STABLE_C_POINTER a while ago with exactly this in mind,
but haven't introduced a new type, which logically should be called
stable_c_pointer and should be defined next to the c_pointer type.
Zoltan.
--------------------------------------------------------------------------
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