Jon Skeet said:
Yes, via JNI. However, that's significantly harder than .NET where you
can just directly call DLL functions - you don't need to write wrapper
libraries in C/C++.
Yup - you have to use another product in order to make the interop
easier.
Well, my own feeling is that interop is the main reason for structs,
but I couldn't say for sure that that was what the designers had in
mind.
Interop is a good reason, perhaps a primary reason, but I think that there
is enough value to justify structures even if interop was non-existant. Its
less common for some, I suppose, but it permits considerable flexibility
which you wouldnt have access to without structures, most notably C#
pointers(which you can treat like C\C++ pointers over a byte array, read in
the array and map the structure over it; this should get a big boost with
the fixed keyword in C# 2.0) and real value semantics for types that need it
rather than immutability and cloning, especially since there is no way to
create copy-on-write semantics other than by using structs or explicit clone
passing(last thing I want is a byclone calling convention).
Value semantics and stack\class inline allocation are rather valuable
things, IMHO. You could go the route that C++ seems to be going for whidbey
and find a way to allocate reference types on the stack, but I think that
would be adding needless complexity to the language(not sure how it works
all in all, I just don't think it fits the C# model. I'm also not sure how
they are passed to non C++ methods) without adding much of the value.