[comp.std.c] "a

jangr@microsoft.UUCP (Jan Gray) (02/06/89)

pANS C accepts "int a();" and "a() {}" but not "a();", which is valid K&R C.
I am curious about the rationale behind this change.  Was it "nobody really
uses that construct, and banning it simplifies the grammar"?

Jan Gray  uunet!microsoft!jangr  Microsoft Corp., Redmond Wash.  206-882-8080

jbuck@epimass.EPI.COM (Joe Buck) (02/07/89)

In article <46@microsoft.UUCP> jangr@microsoft.UUCP (Jan Gray) writes:
>pANS C accepts "int a();" and "a() {}" but not "a();", which is valid K&R C.
>I am curious about the rationale behind this change.  Was it "nobody really
>uses that construct, and banning it simplifies the grammar"?

Not only does nobody use that construct intentionally, but I've seen
problems arise because of typos because of this construct.  I had a
coworker make an error roughly equivalent to

double x, y; func();

(typing a semicolon instead of a comma) which has the effect of
declaring func to return an integer (this is easy to do when you add
an extra variable or function to a declaration).  Under ANSI rules an
error is reported and the problem is corrected.

-- 
- Joe Buck	jbuck@epimass.epi.com, or uunet!epimass.epi.com!jbuck,
		or jbuck%epimass.epi.com@uunet.uu.net for old Arpa sites

Life is not a dress rehearsal.

friedl@vsi.COM (Stephen J. Friedl) (02/07/89)

In article <46@microsoft.UUCP> jangr@microsoft.UUCP (Jan Gray) writes:
>
> pANS C accepts "int a();" and "a() {}" but not "a();", which is valid K&R C.
> I am curious about the rationale behind this change.  Was it "nobody really
> uses that construct, and banning it simplifies the grammar"?

In article <2856@epimass.EPI.COM>, jbuck@epimass.EPI.COM (Joe Buck) writes:
>
> Not only does nobody use that construct intentionally, but I've seen
> problems arise because of typos because of this construct.

I hate to tell you this folks, but this default-type-is-int is
indeed used in a wide body of C code.  Check with your local
archive site for recent the Obfuscated C contest entries.

     Steve :-)

-- 
Stephen J. Friedl        3B2-kind-of-guy            friedl@vsi.com
V-Systems, Inc.       I speak for you only      attmail!vsi!friedl
Santa Ana, CA  USA       +1 714 545 6442    {backbones}!vsi!friedl
Nancy Reagan on these *stupid* .signatures: "Enough already, OK?"