[m-dev.] for review: last call modulo constructors [1/3]

Andrew Bromage bromage at cs.mu.OZ.AU
Wed Jun 24 10:50:12 AEST 1998


G'day all.

My review is on the way, BTW.

Fergus Henderson wrote:

> > +:- type aliasing
> > +	--->		unique	% No aliases.
> > +	;		alias.		% An alias exists.
> > +	% ;		alias_many.	% Many aliases - XXX to be added later.
> 
> It might be useful to document here why you want to keep track of
> which variables have aliases (perhaps mentioning the effect on code
> generation).
> 
> Does `alias' mean exactly one alias?  At most one alias?  At least one alias?

It's actually a marker saying how that var must be updated.

Roughly speaking, a free variable is `unique' if it's a normal free
variable according to the current Mercury code generator.  It is
`alias' if is a free variable in a partially instantiated data
structure.  The idea is that a `unique' var has no representation,
or is represented by junk.  An `alias' var is represented by a
reference (to junk).

The `alias_many' is reserved for cases where not all the references
are known in the current scope, for example, if you have a list_skel
where all of the elements of the list are the _same_ var, and then
you bind that var.  This requires a more exotic representation of
free variables, e.g. indirections or circular lists.

The distinction is important when binding free variables.  For
example, `ref_out' is an implied mode of `out', and requires an
introduced unification to bind the free(alias) var.

> I'm having some difficulty understanding how this is supposed to work.
> 
> Presumably whether or not a variable is aliased depends on what
> else is in scope; so if X is aliased to Y, and then (as you traverse
> down the goal) Y goes out of scope, then X is no longer aliased, right?
> If so, does that mean that mode analysis must update all the
> `free(alias)' insts whenever variables go out of scope?

No.  Once it's free(alias), it's "tainted" until it's bound.

If X is aliased to f(Y), and X goes out of scope, Y is still free(alias),
because when Y is bound, the value must be stored through a reference.

Cheers,
Andrew Bromage



More information about the developers mailing list