Thread overview
reference modifiers
Mar 06, 2004
imr1984
Mar 06, 2004
Ben Hinkle
March 06, 2004
why does D have the reference modifiers in, out, inout, whereas C# has ref. what is the advantage of the D way?


March 06, 2004
"imr1984" <imr1984_member@pathlink.com> wrote in message
news:c2cqmc$8nr$1@digitaldaemon.com...
| why does D have the reference modifiers in, out, inout, whereas C# has ref.
what
| is the advantage of the D way?

from the doc:
The reasons to have them are:
  a.. The function declaration makes it clear what the inputs and outputs to the
function are.
  b.. It eliminates the need for IDL as a separate language.
  c.. It provides more information to the compiler, enabling more error checking
and possibly better code generation.
  d.. It (perhaps?) eliminates the need for reference (&) declarations.
I can't actually find a definition of what in/inout/out do. I guess it's clear
from the
names and the examples but it would be nice to have more details in there.

-Ben


March 08, 2004
Ben Hinkle wrote:
> "imr1984" <imr1984_member@pathlink.com> wrote in message
> news:c2cqmc$8nr$1@digitaldaemon.com...
> | why does D have the reference modifiers in, out, inout, whereas C# has ref.
> what
> | is the advantage of the D way?
> 
> from the doc:
> The reasons to have them are:
>   a.. The function declaration makes it clear what the inputs and outputs to the
> function are.
>   b.. It eliminates the need for IDL as a separate language.
>   c.. It provides more information to the compiler, enabling more error checking
> and possibly better code generation.
>   d.. It (perhaps?) eliminates the need for reference (&) declarations.
> I can't actually find a definition of what in/inout/out do. I guess it's clear
> from the
> names and the examples but it would be nice to have more details in there.
> 
> -Ben
> 
> 

afaik, in provides a copy of the variable, inout a reference to a variable, and out a reference to a variable that has been set to its default value.

But I May Be Wrong. :-o

Cheers,
Sigbjørn Lund Olsen