Path: utzoo!mnetor!uunet!husc6!bbn!mit-eddie!rutgers!columbia!convent!fox From: fox@convent.columbia.edu (David Fox) Newsgroups: comp.lang.c++ Subject: Re: access functions Message-ID: <5547@columbia.edu> Date: 21 Apr 88 16:44:02 GMT References: <8063@apple.Apple.Com> <6590039@hplsla.HP.COM> <11152@mimsy.UUCP> Sender: nobody@columbia.edu Reply-To: fox@convent.columbia.edu (David Fox) Followup-To: comp.lang.c++ Organization: Columbia University Computer Science Dept. Lines: 25 In article <11152@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >The point, however, is that a variable is always >a variable, while a function is arbitrary. So if you declare that >henceforth and forever, anyone can take complexvar.realpart() and >complexvar.imaginarypart(), and you decide you prefer polar coordinates, >people can still take the two, while if you declare that anyone >can simply take .realpart and .imaginarypart, you are stuck with >rectangular. There is really no need for the parentheses after a function that takes no arguments. Envision a preprocessor which builds the symbol table for the program and, when it runs across an identifier which is defined as a function taking no arguments, adds the parentheses. This could also be added to a c++ compiler (or even to a C compiler). Then you could start with a public member and later change it to an access function without hosing your clients. Some might say that the parens are a clue to the object's type, but is this important? I say that a variable really *is* a restricted form of a function that takes no arguments. If something is called 'imaginary_part' then it *is* (or ought to be) the imaginary_part, regardless of what machinations occur during its evaluation. David Fox fox@heathcliff.columbia.edu