Omissible Parentheses...
Ary Borenszweig
ary at esperanto.org.ar
Tue Aug 4 06:16:23 PDT 2009
Benji Smith wrote:
> Denis Koroskin wrote:
>> Stdout("Hello, World!").newline.newline.newline;
>
> Ugh. This is one of the few things about Tango that really drives me
> nuts. I hate all the usage of the opCall overload and non-parenthetized
> function calls.
>
> At first glance, that code doesn't make any sense to me. My brain just
> doesn't grok what's going on. It takes me a split second to mentally
> parse it.
Another thing about omissable parenthesis and function calls. When you
define an opCall, to use it you must write "()". That implies that to
call a function you must write "()". So not writing "()" should imply a
function call!
--
import std.stdio;
struct Bar {
Foo foo;
}
struct Foo {
int opCall() {
return 1;
}
}
void main() {
Bar bar;
writefln("%s", bar.foo); // prints Foo
writefln("%s", bar.foo()); // prints 1
}
--
Isn't that an inconsistency?
More information about the Digitalmars-d
mailing list