Topic: Alternative to "Explicit" keyword
Author: carson@unix1 (John Carson)
Date: 28 May 1994 00:26:34 GMT Raw View
How about allowing a new keyword "exact(ly)" that may be applied to a function
argument that requires the function reference to exactly match the type -
i.e., no conversions allowed? This would not break existing code and would
allow those writing functions, operator overloads, etc. to outlaw conversions.
It should apply to all types of conversions and even promotions.
John Carson
Author: miket@world.std.com (Michael Trachtman)
Date: Sat, 28 May 1994 02:54:53 GMT Raw View
John Carson (carson@unix1) wrote:
: How about allowing a new keyword "exact(ly)" that may be applied to a function
: argument that requires the function reference to exactly match the type -
: i.e., no conversions allowed? This would not break existing code and would
: allow those writing functions, operator overloads, etc. to outlaw conversions.
: It should apply to all types of conversions and even promotions.
: John Carson
How about const'ness?
e.g.
void x (const int exact formal) { ... }
void x0 () { double actual = 2.0; x(actual); } // Not OK, only exact matches.
void x1 () { int actual = 2; x(actual); } // Ok, or not OK ??