On Wed, 29 May 2002 17:54:23 +0200, Arild Fines <[EMAIL PROTECTED]> wrote:
>> -----Original Message----- >> From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of >> Jon Jagger >> In his book, Jeffrey Richter says >> only that it is for reasons best known to and understood by compiler >> writers. Is there a deep reason you hit when implementing the compiler? > >Sure it was Richter's book? I havent read Richter, but I encountered that >exact phrase in Petzold's Programming Windows With C#. I think you are right. Both excellent books though. >FWIW - I think Petzold misunderstood/misrepresented something there. His >example was referring to someControl.Size.Width * 2; something which will >fail because the Size property will return a copy of the Size struct. Making >changes to the Width property of the returned struct will have no effect on >the original and the whole statement is pointless. The compiler recognizes >this and issues a warning(or an error - dont remember offhand). But the whole statement might _not_ be pointless. One of the main points of a property is that a write context you don't get an assignment you get a set accessor. Who is to say what the set accessor does? Suppose for example the set accessor is inside a struct that contains nothing but a reference to some other object and the set accessor forwards on to the referenced object. This seems like a ligitimate and possibly useful technique, so why is it outlawed? Cheers Jon Jagger You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.