www.digitalmars.com         C & C++   DMDScript  

D - Type spec. required for function return value

reply "Sab" <sab neuropolis.org> writes:
It is an "advertised" feature of D not having to specify
"no arguments" case with "(void)":

http://www.digitalmars.com/d/index.html:

    "Functions that have no arguments

    The C Way

               void function(void);

    The D Way

    D is a strongly typed language, so there is no need to explicitly
    say a function takes no arguments, just don't declare it has having
    arguments.

               void function()
               {
                   ...
               }"


OTOH, you still do have to put "void" for functions that
have no return values. This is not an elegant asymmetry.

Would "fixing" that cause ambiguity in the syntax?

Thanks,
Sab
Mar 17 2003
parent "Walter" <walter digitalmars.com> writes:
"Sab" <sab neuropolis.org> wrote in message
news:b5505c$2573$1 digitaldaemon.com...
 It is an "advertised" feature of D not having to specify
 "no arguments" case with "(void)":

 http://www.digitalmars.com/d/index.html:

     "Functions that have no arguments

     The C Way

                void function(void);

     The D Way

     D is a strongly typed language, so there is no need to explicitly
     say a function takes no arguments, just don't declare it has having
     arguments.

                void function()
                {
                    ...
                }"


 OTOH, you still do have to put "void" for functions that
 have no return values. This is not an elegant asymmetry.

 Would "fixing" that cause ambiguity in the syntax?
Yes.
May 02 2003