const(Object)ref is here!
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon Dec 6 10:35:27 PST 2010
Actually I really like the optional usage of ref here because it might
help to disambiguate between a class and a struct object:
E.g.:
class Foo
{
}
struct Bar
{
}
void main()
{
Foo ref foo; // I can be sure Foo is a class
Bar bar;
}
Sometimes it happens that I forget to 'new' a class object, and to the
naked eye the code doesn't appear wrong, but using the optional ref
keyword helps in tracking this kind of bug down. I guess the compiler
should throw an error in cases where Foo is a struct.
More information about the Digitalmars-d
mailing list