[Nickle]Union values

Bart Massey nickle@nickle.org
Fri, 26 Jul 2002 15:58:41 -0700


In message <E17YBOe-0003fQ-00@localhost> you wrote:
[...]
> Now we come to union values.  There are currently four ways of 
> constructing a union value:
> 
> 	<expr>.<member> = <value>		(1) 
> 	<expr> = <type>.<member>		(2) for void members
> 	<expr> = <type>.<member> ( <value> )	(3) for non-void members
> 	<expr> = ( <type>.<member> ) <value>	(4) for non-void members

Note that the third is problematic for functions.  Consider

   typedef void(void) xxx_t;
   typedef union { xxx_t f; } u_t;
   u_t u;
   xxx_t g = void func(void x) {};

   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).

BTW, why are the parens in (4) required?  Just as a grammar
helper?  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, which
might make (4) work better.


> If we agree, I'd like to also propose that the NULL
> pointer values be eliminated from nickle entirely.

A proposal, by the way, due to Andrew Tolmach
<apt@cs.pdx.edu>.


Sorry if some of this is stale.  A lot of e-mail has been
exchanged while I was writing it.

	Bart