Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!sdd.hp.com!uakari.primate.wisc.edu!samsung!uunet!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.std.c++ Subject: Re: foo() => foo Keywords: function call syntax Message-ID: <1074@lupine.NCD.COM> Date: 4 Aug 90 02:40:51 GMT References: <26717@pasteur.Berkeley.EDU> Reply-To: rfg@ncd.com Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 87 In article <26717@pasteur.Berkeley.EDU> krste@ICSI.Berkeley.EDU ( Krste Asanovic) writes: >Suggestion: If a function can be called with no arguments, then it >should be possible to call it without using the superfluous empty >parenthesis. The parens which follow a function designator are definitely *NOT* superfluous. If `f' is a function, then: x = f; says to assign the address of f to the variable x, whereas: x = f (); says to call the function whose designator is f and then assign its return value to the variable x. >It would appear that this would be a fairly minor change. It is >illegal to declare a variable and function with the same name in the >same scope, so there should be no ambiguity (or am I missing something >subtle in the parser?). No, but you did miss something which has been a part of the standard semantics of C and C++ from day one. (Perhaps you are just learning C.) >This allows the user to ignore whether a data >member like object is implemented as a data member or as a member >function. The people who developed Ada had this same idea, and it did in fact wind up in standard Ada. In Ada, if F is a function, and you say: X := F; The function gets called. They (the people who developed Ada) though that this was a swell feature because now users could switch back and forth between F being a variable and F being a (zero-argument) function without changing all the code that makes use of F. Likewise, this was their excuse (oh... sorry... I meant "rationale" :-) for having the same kind of delimiters for either argument lists or subscript lists. In Ada: NUM_NUTS (37) could be either a function call or a array element reference (or even some other things that you don't want to know about). Thus, you could "change implementation" from an array to a function without changing any of the points at which NUM_NUTS was used... or at least that was how the theory was stated back in the early days of Ada. Of course this theoretical mumbo-jumbo introduced by Ada is all nonsense, and fails to take into account the long-understood value of redundancy in languages. Adding explicit (and strictly-speaking "unnecessary") redundancy into a language can make it easier to implement and easier to read. For instance, if I am reading some Ada code, and I see: X := Y; I haven't a clue what Y is, whereas in C or C++, if I see: x = y; I at least know that y is either some kind of a data object (either a variable or a constant) or perhaps (rarely) it is the name of a function, which gets implicitly converted into a (pointer-to-function) data value according to the rules of the language. This fact makes C and C++ code easier to read than Ada code. Let's keep it that way. P.S. For historians, I should note that there have been those who have charged that Ada *actually* avoided using [] for subscripting because of the political clout of some of the really big players of those times (e.g. IBM, CDC, and Honeywell) whose individual "standard" character sets didn't include things like []. The fact that politics was beating out reason in the design of Ada (it has been claimed) then needed to be covered up. That's when this cockamaimy theory about easily changing implementations arose. Disclaimer: The above rumors & inuendos do not reflect the views of NCD, it's management, employees, customers, accountants, lawyers, or even me. As a matter of fact, I didn't even write this. needed to be -- // Ron Guilmette // C++ Entomologist // Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.