Suggestion: object const'ness

Derek Parnell derek at psych.ward
Sun May 21 15:15:29 PDT 2006


On Mon, 22 May 2006 07:44:55 +1000, Tom <ihate at spam.com> wrote:


> Just a few questions, is in/out/inout useful for you in any way?  
> Wouldn't it be more honest to remove in/out/inout and replace it for  
> some kind of 'byref' attribute?

No. I don't come from either C++ or Java background. The 'in' no longer  
scares me now that I can think in D too. In those situations that are  
critical that an object/array passed as a parameter is not modified, I  
pass a copy of that object/array. In other words, as I know that the  
compiler is not helpful in this situation, I take responsiblity for the  
application.

Likewise, if my class returns a reference to something that only the class  
is allowed to modify, I return a copy of that data instead. I know that  
DMD will not help me so I take control.

Yes I know that this is more work on my part and more runtime overheads,  
but it works. So in that sense, DMD is not as sophisticated and helpful as  
C++, but it offers other benefits that outweight this blemish.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d mailing list