From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9ee195735ac5bf6f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1993-03-07 12:34:23 PST Path: sparky!uunet!haven.umd.edu!darwin.sura.net!dtix.dt.navy.mil!mimsy!alex From: alex@cs.umd.edu (Alex Blakemore) Newsgroups: comp.lang.ada Subject: Re: Function call or variable? Message-ID: <64872@mimsy.umd.edu> Date: 7 Mar 93 20:27:06 GMT References: <9303051531.aa21226@Paris.ics.uci.edu> Sender: news@mimsy.umd.edu Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Date: 1993-03-07T20:27:06+00:00 List-Id: In article <9303051531.aa21226@Paris.ics.uci.edu> lhuynh@siam.ICS.UCI.EDU (Thomas Huynh) writes: > how can one determine if the identifier "func_or_var" > is a function call or variable? > if (func_or_var) [then] you cant tell by looking at the reference, but have to look at the definition. that is IMHO a _very_ good thing. it means that the implementation can change between parameterless function and constant and variable and client code need not be modified. similarly, you can change between a function and an array without changing client code. the semantics are the same, just the implementation has changed. this doesnt mean that you shouldnt care about how something is implemented, but that you should only record that design decision in one place instead of propogating the info throughout the code. the same principle that makes private types so useful. if not convinced, consider this scenario, you have a constant or variable referenced throughout your code - and as time goes on, the code to keep it set correctly gets more and more complex and needs to be invoked from more and more places. In Ada, you can replace the variable with a function safely. Code that only references the variable need not change at all. in C, you would have to modify every caller. this syntactic ambiguity allows better information hiding of implementation details. the compiler needs to know the details, but the caller doesnt. overloading is another example of a useful apparent ambiguity, which the compiler resolves based on complete information from the definition. for this reason, I really object to coding styles which try to distinguish syntactically those things that the language intentionally does not. such as using a space or not before left parens to tell distinguish function calls from array references. thats a bad idea. -- --------------------------------------------------- Alex Blakemore alex@cs.umd.edu NeXT mail accepted