TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: Bruce MacKenzie 71725,376 (X)
from: Zack Sessions 76407,1524
date: 1990-05-30 22:19:00
subject: #4002-#C and JOoysticks

#: 4014 S3/Languages
    30-May-90  22:19:00
Sb: #4002-#C and JOoysticks
Fm: Zack Sessions 76407,1524
To: Bruce MacKenzie 71725,376 (X)

I don't think is strong at all to say that it is the K&R standard. After all,
if you look on page 68 and 70 of K&R, you'll plainly see that the format of the
return statement is "return(expression)". On page 68, the book goes on to say,
that the main purpose of the return statement is not to simply return to the
caller but to return a value to the caller, but if no value is expected by the
caller, then no expression is needed at all, in which case the returned value
is garbage. It doesn't mention it, but the "accepted" standard for that form of
the return statement is sio simply "return" with no parentheses at all.

Admittedly, in the appendix on page 203, the return statement is described with
it's expression not enclosed in quotes, so there is some ambiguity, but I
disagree that it "is common style". I have seen a lot of C code on several
different platforms in the past few years, and NOWHERE have I seen the return
statement used to pass a value without the parentheses. It may be YOUR common
style, but it not EVERYBODY'S common style.

But, since the compiler apparently accepts it inthe format which you describe,
then the usage of parentheses is a matter of personal preference, but I don't
recommend it's use, as other compilers may croak. I don't have a copy of the
second printing of K&R (based on the ANSi standard) so I'm not sure if the
current standard requires the () or not.

Zack

There are 2 Replies.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.