I think the main issue here is that teh DirectX API (which this was about in the beginning) does not pass the structy by ref.
Looks like a tremendous oversight to me. The rest then is basically a logical extension of standard .NET semantics (structs copied onto stack) and not perfect optimizations (that are also not really wanted). Has anyone a clue whether there may be a reason they are not defined as ref? Thomas Tomiczek THONA Software & Consulting Ltd. (Microsoft MVP C#/.NET) > -----Original Message----- > From: Unmoderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of > Reali Patrik René Celeste > Sent: Montag, 17. Mai 2004 09:35 > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Large structures > > Jeroen Frijters wrote: > > Arlie Davis wrote: > > > Or does it ever simply pass a pointer to the structure? > > > > In theory it could do this optimization in some cases, but I don't > > think it is likely that they'll do it in practice. If you > want to pass > > large structures, you can always pass them by reference (unless, of > > course, you're calling someone else's API, like in your case). > > > > I guess this won't happen: this requires the compiler to > check that the value is never changed in the invoked method > (easy) and to change the method's signature (nasty). If you > recompile your class and the compiler decides to optimize > that method, it will change its signature, invalidating all > the calls (makes sense only for private and internal methods > where all call sites are known). > > > > I like value types. However, structures of any > significant size are > > > just impractical, if they must always be copied. > > > > It's a lot worse than you (and I) expected. Initially I created a > > value type with 16 floats, to do something equivalent to > the DirextX > > Matrix (I don't have the managed DirectX sdk installed), but after > > having seen that I decided to create a really large value > type, 100000 > > floats. My test program died with an > InvalidProgramException. This is, > > of course, bogus. The spec says that a value type can be up > to 1 MByte > > (and there is even a note that says that the "current" Microsoft > > implementation allows 4 Mbyte). > > The structure size is one thing. In my experience, exceptions > while passing a big structure are usually stack overflows. > > > -Patrik > > =================================== > This list is hosted by DevelopMentor® http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== This list is hosted by DevelopMentor® http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com