[Nickle]Union values

Keith Packard nickle@nickle.org
Fri, 26 Jul 2002 16:30:35 -0700


Around 15 o'clock on Jul 26, Bart Massey wrote:

>    u_t v = u_t.f(g);  /* init */
>    void v = v.f(<>);  /* call */
> 
> While these last two lines are distinct, it seems confusing
> to me.  I don't want to think about it :-).  IMHO, lose (3),
> not (4).

You could think of the u_t.f (g) form as a union value constructor 
invocation, but it's certainly less clear that way.  I can do (4) if
you'd prefer; it's just a grammar tweak in either case.

> BTW, why are the parens in (4) required?

Yeah; without a known token, the grammar can't tell when the following 
expression is an initializer or something following a void union value:

	typedef union { int i; void v; } u;

	u x;
	poly y;

	x = u.v * y;

Attempting to permit this syntax results in 54 shift/reduce conflicts.

> If so, I'd note that as long as the lexer is
> tracking typenames anyway, it could also track which ones
> are bound to union types and return a different token,

The lexer can't compute the value of a type expression and use that to 
control the parser; all it can do is look at a single token.

> > pointer values be eliminated from nickle entirely.
> 
> A proposal, by the way, due to Andrew Tolmach
> <apt@cs.pdx.edu>.

Yes, I'd forgotten to mention that part -- as usual, the simplest solution 
is to eliminate the problem, rather than piling yet more kludges on.

-keith