Standard C Digest - V2 #7

Orlando Sotomayor-Diaz osd7 at homxa.UUCP
Thu Jan 10 23:36:11 AEST 1985


ANSI Draft of Proposed  C Language Std.

Mail your replies to the author(s) below or to cbosgd!std-c.
Cbosgd is reachable via most of the USENET nodes, including ihnp4,
ucbvax, decvax, hou3c....  Administrivia should be mailed to 
cbosgd!std-c-request.

ARPA -> mail to cbosgd!std-c at BERKELEY.ARPA (+++ NOT TO INFO-C +++)

**************** mod.std.c  Vol. 2 No. 7  1/10/85 *******************

Today's Topics:
		On Decot's union initialization scheme (1)
		Conditional expressions and code breaking (1)
----------------------------------------------------------------------

Date: Wed, 9 Jan 85 19:00:30 est
From: cbosgd!gang!hokey
Subject: Dave Decot's Union initialization
References: <604 at homxa.UUCP>

Dave Decot proposes a mechanism for initializing unions which is, effectively,
keyword-based instead of positionally-based.  Similar proposals have been
examined for parameter passing in other languages.

There are two ways to initialize an array under this proposal.  One is to
explicitly specify which array entry is being specified, and the other is
to implicitly state the entry.  These two methods are not mutually exclusive.
It would, in my opinion, be gross if the explicit array "offset" had to be
specified only on the lhs.  For example:

struct bar[3]
{
	union foo
	{
		char   array[4];
		double mint;
	} foo1, foo2;

	int i;
};

struct bar x =
{
    {		/* implicitly initializes the first [0] element */
	.i = 2,
	.foo2 =
	{
		.array = { '2', '4', '6', '8' }
	}
    },
 [3]{
	.foo1 =
	{
		.mint = 3;	/* does this need to be cast? */
	}
	.i = 1
    }
};

This example probably needs some changes.

Personally, I prefer positional binding over keyword binding for union
initialization because I don't want to have to type in all the keywords
for each entry of a large table.  Also, if I decide to change the name
of one of the elements, I have a lot more stuff to change (yes, I know
this can be easy with a good editor).

----------------------------------------------------------------------

Date: Wed, 9 Jan 85 10:44:44 pst
From: cbosgd!ucbvax!ucsfcgl!arnold (Ken Arnold)
Subject: Standard breaks code

My last major submission was a series of three things in the standard
which broke existing code.  I have found a fourth, and I highly
recommend that this, too, be fixed.  As mentioned by numerous people,
the new standard should never break existing code, as much as we may
want some (perceived) misfeature addressed.

(By the way, I have lots of comments on other problems and questions
with the standard, which I am currently compiling into an organized
fashion, and which I will then send to this group in reasonably-sized
bunches).

*Problem:	Breaks Code
*Reference:	C.3.15 Condition operator; Syntax
*Description:

"conditional-expression:
	logical-OR-expression
	logical-OR-expression ? logical-OR-expression : conditional-expression"

This description of syntax, unfortunately, does not allow the quite
reasonable expression

	a ? b ? c : d : e

which is unambiguously equivalent to

	a ? (b ? c : d) : e

It insists that any non-parenthesized conditional expression be on the
right-hand side of the ':', which is a new restriction, and hence can
break existing code.  This must be changed.  Although this may violate
some constraint on grammar declaration (I haven't examined it fully)
the obvious manner to change it is

conditional-expression:
	logical-OR-expression
	logical-OR-expression ? conditional-expression : conditional-expression

		Enjoy,
			Ken Arnold
======================================================================
"Of COURSE we can implement your algorithm.  We've written this Turing
machine simulator..."
------------------------------------------------------
End of Vol. 2, No. 7. Std-C  (Jan. 10, 1985  08:30:00)
-- 
Orlando Sotomayor-Diaz	/AT&T Bell Laboratories, Red Hill Road
			/Middletown, New Jersey, 07748 (HR 1B 316)
Tel: 201-949-9230	/UUCP: {ihnp4, houxm}!homxa!osd7  



More information about the Mod.std.c mailing list