D - in and inout, are they different?
- Tydr Schnubbis (6/6) Apr 18 2004 Apart from the obvious difference in their intended usage, are they
- C. Sauls (9/16) Apr 18 2004 The 'inout' attribute essentially means pass-by-reference, 'in' is just
- Tydr Schnubbis (9/16) Apr 18 2004 Sorry, I meant to ask about the difference between out and inout, not in
- =?ISO-8859-1?Q?Sigbj=F8rn_Lund_Olsen?= (6/23) Apr 24 2004 'out' will set the variable to its .init value. So if you pass a float
Apart from the obvious difference in their intended usage, are they different? Does inout guarantee that a variable has been assigned to prior to being used as an argument? Do both inout and out guarantee that they parameters will be assigned to inside the function? I think Tor
Apr 18 2004
The 'inout' attribute essentially means pass-by-reference, 'in' is just there for completeness and means to use whatever the default is (pass-by-value for pretty much everything, pass-by-reference for classes). And no they don't gurantee assignment, but since all D variables have a default value (.init) one could argue that they are technically guranteed to have something anyhow. -C. Sauls -Invironz Tydr Schnubbis wrote:Apart from the obvious difference in their intended usage, are they different? Does inout guarantee that a variable has been assigned to prior to being used as an argument? Do both inout and out guarantee that they parameters will be assigned to inside the function? I think Tor
Apr 18 2004
Tydr Schnubbis wrote:Apart from the obvious difference in their intended usage, are they different? Does inout guarantee that a variable has been assigned to prior to being used as an argument? Do both inout and out guarantee that they parameters will be assigned to inside the function? I think TorSorry, I meant to ask about the difference between out and inout, not in and inout. But I guess any guarantee that an inout parameter, if a variable, has been assigned to before used as an argument, would apply to in as well. I realize that being forced to assign to a variable to avoid compiler errors or warnings might be annoying if you are happy with the default value. But to have this kind of enforcement could also be very useful. Tor
Apr 18 2004
Tydr Schnubbis wrote:Tydr Schnubbis wrote:'out' will set the variable to its .init value. So if you pass a float with 0.75 as an out, it will be set to NaN as it is passed to the function. inout doesn't do this, the value of 0.75 is left alone. Cheers, Sigbjørn Lund OlsenApart from the obvious difference in their intended usage, are they different? Does inout guarantee that a variable has been assigned to prior to being used as an argument? Do both inout and out guarantee that they parameters will be assigned to inside the function? I think TorSorry, I meant to ask about the difference between out and inout, not in and inout. But I guess any guarantee that an inout parameter, if a variable, has been assigned to before used as an argument, would apply to in as well. I realize that being forced to assign to a variable to avoid compiler errors or warnings might be annoying if you are happy with the default value. But to have this kind of enforcement could also be very useful.
Apr 24 2004