M
Magnus Lidbom
I'm not sure what you mean. If you mean the ability to pass a Foo(inline)
This is fairly obvious of course, but what about this: (taking your
classes)
//const supporting assembly
class Foo
{
private int m_value;
public static const Foo GetInstance(){return new Foo();}
public void CalculateNewValue()
{
m_value = Bar.NewRandomValue() * 10;
}
public int Value
{
//declare get const.
get const
{
return m_value;
}
set
{
m_value = value;
}
}
}
Now, CalculateNewValue obviously manipulates an instance of Foo's
value. However if you do not want that to happen, you should be able to
specify that.
reference around upon which CalculateNewValue cannot be called, then
thats just a const reference. This is a bit to obviuos though. I
doubt that's what you're getting at.
Actually, you couild't compile the method. It modifies a non mutableWith the GetInstance() method this should be prevented. I
also can't declare CalculateNewValue() as const, because then I can never
call it (as I understand it) because it would always alter the state of
the object. (if this is a misunderstanding, ignore my posting)
field, so it can't be const.
No. Just it's declaration. This discussion is probably moot though. MyTo determine if a call to CalculateNewValue() is violating the
contract in a non-const support language, the compiler has to examine
CalculateNewValue(),
idea for validating IL from non supporting languages was flawed. See
the other subthread for details.
/Magnus Lidbom