Is this really a bug?

Daniel daniel.maciel at gmail.com
Fri Jan 6 17:19:34 PST 2012


Hi, I've read on Bugzilla Issue 6398 that this is a bug:

static int value;
ref foo(){ printf("getter\n"); return value; }
ref foo(int x){ printf("setter\n"); value = x; return value; }

void main(){ foo = 1; }  // Should print "setter", but print "getter" in 2.054

But, this is pretty convenient syntax, no? That way you could implement only one function foo() and use it as setter and getter.

I'm a bit confused about it.

Thanks,
Daniel


More information about the Digitalmars-d-learn mailing list