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

Reply via email to