On Thu, Feb 25, 2016 at 1:27 PM, Jeff Squyres (jsquyres) <jsquy...@cisco.com
> wrote:

> I still find it fairly astounding that the naked word "rank" (vs "rank()")
> is ambiguous with a variable and a function call.  I wouldn't be surprised
> by this in a scripting language; if this really is true in C++, that's
> quite surprising to me.


A "bare" function name (without parens) is the address of the function,
which can be converted to an int, long, etc.
So the "rank" identifier can validly refer to the function in this context.

This is no different than C with respect to typing rules:

$ cat foo.c
#include <stdio.h>
int main(void) { printf("%ld\n", main); }
$ gcc -o foo foo.c
$ ./foo
134513448


-Paul

-- 
Paul H. Hargrove                          phhargr...@lbl.gov
Computer Languages & Systems Software (CLaSS) Group
Computer Science Department               Tel: +1-510-495-2352
Lawrence Berkeley National Laboratory     Fax: +1-510-486-6900

Reply via email to