www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Statement with no effect

reply "Bob W" <nospam aol.com> writes:
One of the differences between D and C seems
to be that I am able to call D functions without
parameters by simply omitting the empty
brackets:

So
         test();
or
         test;
will give equivalent results.

In C only the first statement will work. The
other one will result in a warning and otherwise
gets ignored.

I am lazy enough to like the idea that I can
omit the brackets if I'd wish to, but I also
want to ensure that future versions of dmd
will still allow me to do that.

???
Feb 06 2006
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Bob W" <nospam aol.com> wrote in message 
news:ds8k29$qt0$1 digitaldaemon.com...
 I am lazy enough to like the idea that I can
 omit the brackets if I'd wish to, but I also
 want to ensure that future versions of dmd
 will still allow me to do that.
This is a result of the "implicit property syntax" in D, which is a feature, and which doesn't seem to be going away. So don't worry :)
Feb 06 2006
next sibling parent "Bob W" <nospam aol.com> writes:
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:ds8nfc$t5o$1 digitaldaemon.com...
 "Bob W" <nospam aol.com> wrote in message 
 news:ds8k29$qt0$1 digitaldaemon.com...
 I am lazy enough to like the idea that I can
 omit the brackets if I'd wish to, but I also
 want to ensure that future versions of dmd
 will still allow me to do that.
This is a result of the "implicit property syntax" in D, which is a feature, and which doesn't seem to be going away. So don't worry :)
I won't, thanks.
Feb 07 2006
prev sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Jarrett Billingsley wrote:
 "Bob W" <nospam aol.com> wrote in message 
 news:ds8k29$qt0$1 digitaldaemon.com...
 I am lazy enough to like the idea that I can
 omit the brackets if I'd wish to, but I also
 want to ensure that future versions of dmd
 will still allow me to do that.
This is a result of the "implicit property syntax" in D, which is a feature, and which doesn't seem to be going away. So don't worry :)
I've always been a bit unsure about this. Firstly, it _looks_ like an effectless (and therefore illegal) statement, and as such is likely to arouse the suspicion of anybody who reads the code. Secondly, I had previously got the impression that, when you use a function name, you had to do one of the following with it: - assign to it - use it as an rvalue in an expression - take its address Using it on its own for an ExpressionStatement isn't doing any of these, and so there's nothing disambiguating how the function name is being used. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Feb 07 2006