[m-dev.] Question about WAM style variables in Mercury
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Feb 5 15:17:36 AEDT 2004
On 05-Feb-2004, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Fergus Henderson, Thursday, 5 February 2004:
> > On 05-Feb-2004, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > > For adding Herbrand types to the language, it would be good if WAM style
> > > variables didn't require heap allocation, but instead just formed direct
> > > pointer chains.
> > >
> > > However, this would mean having pointers to the interior of cells rather
> > > than the start of a cell.
> >
> > How so? Could you explain in more detail?
>
> Consider this Mercury snippet:
>
> X = f(A, B), % Construct f/2, A & B are unbound Herbrand vars.
> Y = g(C, D), % Construct g/2, C & D are unbound Herbrand vars.
> A = D, % Alias A and D.
> B = C % Alias B and C.
>
> The C code for the constructions using non-heap allocated WAM variables
> could be something like
>
> X = <<construct f/2 cell>>;
>
> A = &X[0]; % ) Initialize A.
> *A = NULL; % )
>
> B = &X[1]; % ) Initialize B.
> *B = NULL; % )
Oh, I see what you mean.
> However, the whole thing already looks a tad complicated and, given that
> what you've said about GC issues is as I suspected, I'll just use heap
> allocated WAM variables.
I think that is a good plan, at least for the first cut.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- 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