From: John Lam Date: 2006-02-11T05:00:29+09:00 Subject: Preserve value-type semantics in imported types ------=_Part_1658_9857380.1139601613617 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I'm importing a value type from the CLR and I'd like to preserve value type semantics in Ruby ... I'm not sure this can be done. Consider the Point struct in C# as an example: Point p1 =3D new Point(2, 3); Point p2 =3D p1; // value types get copied in the CLR upon assignment p2.X +=3D 1; Assert.Equals(p1.X + 1, p2.X); So the equivalent code that uses my RubyCLR bridge doesn't display the equivalent semantics: p1 =3D Point.new(2, 3) p2 =3D p1 # the object reference gets copied in Ruby, so this is now an al= ias p2.X +=3D 1 assert_equal p1.X, p2.X The value types are stored as opaque blobs in Ruby's T_DATA struct. Since I can't overload the assignment operator, are there any tricks that can help me? Or do I have to write a custom implementation of clone for value types that memcpys the T_DATA struct? Thanks -John http://www.iunknown.com ------=_Part_1658_9857380.1139601613617--