|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - passing null to an out parameter
ok i want to do something like this:
void setInt(out int myInt)
{
if(&myInt!= null)
myInt = 0xfoobar;
}
int main()
{
int x;
setInt(x);
setInt(null);//this requires a cast to do such as *(int*)null
return 0;
}
Can we please be allowed to pass null to an out parameter if we dont need it?
Apr 29 2004
imr1984 wrote: Apr 29 2004
ok so say you have a function that optionally returns a value through a passed pointer. If you declare a variable to store that returned value, dmd will generate automatically the initialising code for that storage variable, even though it will just be a waste of time; because dmd cant know that the function doesnt read the value, it just writes to it. Whereas if you could pass null to out parameters then this overhead would be avoided. This is why it is a good idea to allow null to be passed to an out param. In article <c6qv67$16mf$1 digitaldaemon.com>, J Anderson says...imr1984 wrote: Apr 29 2004
imr1984 wrote:ok so say you have a function that optionally returns a value through a passed pointer. If you declare a variable to store that returned value, dmd will generate automatically the initialising code for that storage variable, even though it will just be a waste of time; because dmd cant know that the function doesnt read the value, it just writes to it. Whereas if you could pass null to out parameters then this overhead would be avoided. This is why it is a good idea to allow null to be passed to an out param. Apr 29 2004
"imr1984" <imr1984_member pathlink.com> wrote in message news:c6qni2$rdc$1 digitaldaemon.com... Apr 30 2004
|