473,465 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Empty parentheses

I understand the rationale behind declaring function definitions such as

int main() { return 0; } /* empty parentheses */

obsolete, but I haven't been able to find out why Dennis Ritchie despised them
enough to call them an "abomination." Comments and/or links appreciated.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 13 '05 #1
10 3865
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bm**********@chessie.cirr.com...
I understand the rationale behind declaring function definitions such as

int main() { return 0; } /* empty parentheses */

obsolete, but I haven't been able to find out why Dennis Ritchie despised them
enough to call them an "abomination." Comments and/or links appreciated.


IIRC, the empty parens is the same as:

int main(...);

which means variable number of arguments. VARARGS
are pita, and have implementation-dependent issues.

If you really want an empty parameter list,
then the proper declaration is:

int main(void);

My brain is fuzzy on this, so if I made a boo-boo
here, please correct me.

Nov 13 '05 #2
"xarax" <xa***@email.com> wrote in
news:Qm***************@newsread4.news.pas.earthlin k.net:
I understand the rationale behind declaring function definitions such
as

int main() { return 0; } /* empty parentheses */

obsolete, but I haven't been able to find out why Dennis Ritchie
despised them enough to call them an "abomination." Comments and/or
links appreciated.


IIRC, the empty parens is the same as:

int main(...);


No, it doesn't. It means use the first-encountered usage to complete
the prototype.

--
- Mark ->
--
Nov 13 '05 #3
In <bm**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
I understand the rationale behind declaring function definitions such as

int main() { return 0; } /* empty parentheses */

obsolete, but I haven't been able to find out why Dennis Ritchie despised them
enough to call them an "abomination."


Please elaborate.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #4
In <Xn********************************@130.133.1.4> "Mark A. Odell" <no****@embeddedfw.com> writes:
"xarax" <xa***@email.com> wrote in
news:Qm***************@newsread4.news.pas.earthli nk.net:
I understand the rationale behind declaring function definitions such
as

int main() { return 0; } /* empty parentheses */

obsolete, but I haven't been able to find out why Dennis Ritchie
despised them enough to call them an "abomination." Comments and/or
links appreciated.


IIRC, the empty parens is the same as:

int main(...);


No, it doesn't. It means use the first-encountered usage to complete
the prototype.


Nope, it doesn't. It means this definition/declaration doesn't
provide a prototype for this function.

You're *severely* confused if you believe that the the
first-encountered usage has any relevance whatsoever. The following
code does NOT require any diagnostic:

void foo();
...
foo(1);
foo(1, 2);
foo(1, 2, 3);

although it's obvious that at most one of these calls can be correct.
It's a clear case of undefined behaviour.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #5
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
# I understand the rationale behind declaring function definitions such as
#
# int main() { return 0; } /* empty parentheses */
#
# obsolete, but I haven't been able to find out why Dennis Ritchie despised them
# enough to call them an "abomination." Comments and/or links appreciated.

P'raps in comparison to how Algol 60 and 68 and Pascal and other such
languages handle the same issue.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
God's a skeeball fanatic.
Nov 13 '05 #6
Dan Pop <Da*****@cern.ch> spoke thus:
Please elaborate.


Basically, I want to know how Dennis Ritchie and the Standards Committee can
arrive at diametrically opposed positions regarding empty parentheses. Why
does Dennis believe the syntax should be retained? Presumably it isn't
because he's a crackpot, because various important people (like Bjarne
Stroustrup) agree with his reasoning.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 13 '05 #7
Da*****@cern.ch (Dan Pop) wrote in news:bm**********@sunnews.cern.ch:
I understand the rationale behind declaring function definitions such
as

int main() { return 0; } /* empty parentheses */

obsolete, but I haven't been able to find out why Dennis Ritchie
despised them enough to call them an "abomination." Comments and/or
links appreciated.

IIRC, the empty parens is the same as:

int main(...);


No, it doesn't. It means use the first-encountered usage to complete
the prototype.


Nope, it doesn't. It means this definition/declaration doesn't
provide a prototype for this function.


What should I have said?

--
- Mark ->
--
Nov 13 '05 #8
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bm**********@chessie.cirr.com...
Dan Pop <Da*****@cern.ch> spoke thus:
Please elaborate.


Basically, I want to know how Dennis Ritchie and the Standards Committee can
arrive at diametrically opposed positions regarding empty parentheses. Why
does Dennis believe the syntax should be retained? Presumably it isn't
because he's a crackpot, because various important people (like Bjarne
Stroustrup) agree with his reasoning.


I believe the issue has been slightly misstated. The original C language
that Ritchie developed had no mechanism for making the argument types a
part of the function type. The C committee added what we call function
prototypes to remedy what was widely perceived as a clear deficiency.
(We modeled those prototypes largely on previous C++ work, but not entirely.
For example, I had developed a commercial C compiler as early as 1975 that
had something similar.)

The quandary we then faced was what to do about backward compatibility.
Ritchie stated a strong dislike for having two mechanisms that did much
the same thing, only differently. The committee was sympathetic with that
view, but had a practical problem to solve. So we left the 'T f()' notation
to declare f as a function returning T with no constraints on argument
types. We also added 'T f(void)' as a way of clearly stating that f was
constrained to have no arguments, and the ... notation for a varying length
argument list with no type constraints. The rules for mixing old and new
style declarations and definitions we worked out to minimize surprises.
(A major contribution was Sam Harbison's rule about implicit prototypes,
which we quickly dubbed the Miranda Rule.)

None of us liked having two similar but different rules for declaration.
Many of us regretted parting company with C++ on the meaning of 'T f()'.
Ritchie was gracious enough to acknowledge that what we did was probably
necessary, however undesirable. I haven't heard the term 'abomination'
applied to this situation (except possibly by C++ zealots) for nearly
20 years now.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Nov 13 '05 #9

On Fri, 17 Oct 2003, Mark A. Odell wrote:

Da*****@cern.ch (Dan Pop) wrote in news:bm**********@sunnews.cern.ch:
[Mark A. Odell wrote:]

No, it doesn't. It means use the first-encountered usage to complete
the prototype.


Nope, it doesn't. It means this definition/declaration doesn't
provide a prototype for this function.


What should I have said?


From Dan's response, I gather that you should have said,
"No, it doesn't. It means use the first encountered *prototype*
to complete the prototype, and *until then* just assume that the
user wants the default promotions applied to the arguments in
any calls to that function."

A function "usage" means a function call, I'd say:

foo(1) foo("abcd")

A function "prototype" means a prototype:

int foo(int); void foo(const char *p) { }
HTH,
-Arthur
Nov 13 '05 #10
Arthur J. O'Dwyer wrote:

On Fri, 17 Oct 2003, Mark A. Odell wrote:

Da*****@cern.ch (Dan Pop) wrote in news:bm**********@sunnews.cern.ch:
[Mark A. Odell wrote:]
>>
>>No, it doesn't. It means use the first-encountered usage to complete
>>the prototype.
>
> Nope, it doesn't. It means this definition/declaration doesn't
> provide a prototype for this function.


What should I have said?


From Dan's response, I gather that you should have said,
"No, it doesn't. It means use the first encountered *prototype*
to complete the prototype, and *until then* just assume that the
user wants the default promotions applied to the arguments in
any calls to that function."


Still not quite right, I'm afraid. Going by the OP's example code
we're talking about an empty argument list in a function /definition/.
In this case the function is defined to take no arguments, and calls
to the function which supply arguments have undefined behaviour (and
so need not be diagnosed) unless there's a separate prototype in scope
in which case such calls violate a constraint.

Jeremy.
Nov 13 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
44
by: seberino | last post by:
Tuples are defined with regards to parentheses ()'s as everyone knows. This causes confusion for 1 item tuples since (5) can be interpreted as a tuple OR as the number 5 in a mathematical...
10
by: David Graham | last post by:
Hi I have been busy going through the last weeks postings in an attempt to absorb javascript syntax (I guess it's not possible to just absorb this stuff in a passive way - I'm getting way out of...
4
by: Thelma Lubkin | last post by:
I've inherited code with SELECT statements that look like this one: SELECT tblSales.YEAR As , Count(tblSales.UNITS) As FROM INNER JOIN tblSales ON .STFID = tblSales.STFID WHERE...
10
by: arnuld | last post by:
this is from Steve Summit C notes: The empty pair of parentheses indicates that our main function accepts no arguments, that is, there isn't any information which needs to be passed in when the...
31
by: noagbodjivictor | last post by:
How to check if a string is empty in python? if(s == "") ??
3
by: Lyn | last post by:
Can anyone explain this for me? A sub procedure can be called with or without parentheses around the arguments. By personal convention, I normally use parentheses. I am in the middle of a...
7
by: vlsidesign | last post by:
I am not sure how to think about parentheses. It seems when they are used alongside characters it indicates a function, like addTwoNums(). But is also is used to enforce which operators and...
20
by: Sun | last post by:
Maybe this is a very primative question, but I just get a bit confused about 'set' and 'Set' module in python. I understand 'set' is a build in type in python after 2.4(or 2.3) and Set a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.