home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!uunet.ca!frumious!pat
- From: pat@frumious.uucp (Patrick Smith)
- Subject: Re: The fate of my exponentiation operator proposal
- Message-ID: <BzCFyM.2r5@frumious.uucp>
- Date: Wed, 16 Dec 1992 08:37:33 GMT
- References: <1992Dec05.002934.13043@microsoft.com> <1992Dec5.063533.1787@frumious.uucp> <1992Dec07.195917.14566@microsoft.com>
- Organization: None
- Lines: 73
-
- jimad@microsoft.com (Jim Adcock) writes:
- |In article <1992Dec5.063533.1787@frumious.uucp> uunet.ca!frumious!pat writes:
- ||jimad@microsoft.com (Jim Adcock) writes:
- |||Where is the offsetting benefit in *requiring* implementations to make this
- |||change breaking conforming programs? ANSI-C *already* requires that
- |||macro implementations only perform one evaluations of the macro parameters,
- |||so what are you gaining by forcing implementations to now use inline
- |||functions instead of macros for these things?
- ||
- ||If these functions may be implemented as macros, then their names may not
- ||be used in other ways (not by programmers who aspire to write portable
- ||code, anyway). For example, consider
- ||
- || class Prisoner {
- || public:
- || // ...
- || void free(); // Let him out on parole; not related to malloc()
- || };
- |
- |Agreed. You give an excellent example of why ANSI-C functions should
- |continue to be implemented as macros not as inlines.
-
-
- I take it you consider the above to be an unreasonable use of the
- name free. Perhaps it is and perhaps it isn't; people often have
- different opinions as to what's reasonable. In the absence of a
- strong concensus that something is unreasonable, I would prefer to
- allow those who believe it to be reasonable to do it.
-
-
- Here are a few other examples you might find more convincing.
-
- Consider the above in the context of a project where malloc() and the
- normal free() are never used; all memory allocation is done through
- new and delete.
-
- Steve Clamage mentioned the possibility of using sin to refer to
- immoral acts, instead of the sine function.
-
- In some cases, an existing name from the standard library can
- be quite intuitive as a name for a new function. For example,
-
- class String {
- // A sequence of characters, possibly including null characters
- // in arbitrary positions.
- public:
- size_t length() const;
- // Length of the sequence, including the nulls (if any).
- size_t strlen() const;
- // The number of characters before the first null character
- // (not including the null); the same as length() if there
- // aren't any nulls in the string.
- };
-
- Stepping to another language for a moment, there's a problem with
- this C code, if memory serves me correctly:
-
- typedef whatever Razor;
- void strop(Razor r);
-
- The problem? The C standard reserves names beginning with str for
- use in future versions of the standard. So this code might not
- compile a few years down the road. If one takes this restriction
- seriously, there are quite a few normal English words one shouldn't
- use in C programs (strong, straight, stress, strict, etc., etc.).
- It would be nice to be able to use these words in C++ programs
- without having to worry about future versions of the standard,
- even if only in some contexts (eg. as member function names).
-
- --
- Patrick Smith
- uunet.ca!frumious!pat
- pat%frumious.uucp@uunet.ca
-