At 3:29 PM -0500 1/5/03, attriel wrote:
> At 6:56 PM +0530 1/4/03, Gopal V wrote:
If memory serves me right, Erik Bågfors wrote:
> >> would a be able to modify itself ? (unfortunately C# allows
that)
> >
To clarify here's my example ...
=cut
using System;
public struct MyStruct
{
int val;
public MyStruct(int x){ val=x; }
public void Modify(){ val=42; }
public override String ToString(){ return val.ToString(); }
}
public class FooBar
{
public static void Main()
{
MyStruct m1=new MyStruct(10);
MyStruct m2=m1;
m1.Modify();
Console.WriteLine(m1);
Console.WriteLine(m2);
}
}
=end cut
Which gives
42
10
If in anycase Parrot wants to avoid this , we could always add a
special case to the ILNode_Assign to generate an explicit copy step in
parrot for valuetypes...
Why would we want to avoid this? It looks exactly like what ought to
happen.
I think he was explaining what he meant in another post that someone
questioned, with this example; then the "wants to avoid this" referred to
"avoiding the easy-path error of NOT doing this". I think Gopal was
saying that C#/NET does it that way, and I can't imagine him asking to
have functionality he explicitly needs to be "carefully avoided" :)
Just because C# does it doesn't mean that he likes it. :)
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk