From: John Lam Date: 2006-02-11T07:20:54+09:00 Subject: Re: Preserve value-type semantics in imported types ------=_Part_3254_7658083.1139610035094 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thanks, Nori! Perhaps it wasn't super clear in my example, but this line of code: p =3D Point.new(3, 4) actually creates a new CLR Point value type inside of a Ruby VALUE object. = A CLR value type is an opaque blob of data (but in this case is really a couple of 32 bit integers packed together), so I store it in a T_DATA struct. So I allocate enough memory to hold the value type, and tell the CL= R to create the value type at the address of the T_DATA struct in the VALUE object. X and Y are properties defined in the Point value type class in the CLR. They map to accessor methods get/set_X and get/set_Y. My RubyCLR bridge map= s these things automagically through liberal use of const_missing and method_missing. So I can't change these names even if they aren't Ruby-esque. Those are the case-sensitive method and property names defined by the value type in the CLR. I guess the real issue is that I don't think there's a way to force value type semantics onto Ruby reference types. It would be nice to preserve CLR value type semantics inside of Ruby, but hey- they're different type system= s so you need to abide by the rules of those type systems. I'm just worried that it might introduce bugs in code that use my bridge: p1 =3D p2 is just so much more intuitive than p1 =3D p2.clone If you're curious about my RubyCLR bridge, you can download my first public drop of the bits here: http://www.iunknown.com/articles/2006/01/12/first-drop-of-rubyclr I'm working on a new drop that marshals value types correctly - hence this question on the list. Hopefully I'll have support early next week for folks to play with. Thanks -John http://www.iunknown.com ------=_Part_3254_7658083.1139610035094--