D - Request for feature or bug?
- MicroWizard (55/55) May 05 2002 Request for feature or bug?
- Pavel Minayev (6/8) May 05 2002 I would suggest to put it into the same category as the array bounds
- MicroWizard (3/11) May 05 2002 I agree completely.
- OddesE (10/18) May 05 2002 null
- Matthew Wilson (5/13) May 06 2002 Is there some distinction in the compiler/libraries between debug and
- Pavel Minayev (9/11) May 06 2002 In release build, compiler removes all assertions, invariant calls and
Request for feature or bug? I don't find anything in the documentation about that: Should D make any run-time check whether a reference to an object is null or not, before it calls a member function? I wrote the attached program and it hangs up (CTRL-C can terminate :-) if I left out the marked line. Obviously there is a bug in my program in this case. The reference variable was created only and no physical object. I think it is a typical problem for C++ programmers when starting to use D. First I tought the object instance will be created... This bug can be caught only before the call is made to I_don't_know_where, the CPU does not call the member where the catch would also be possible. A run-time check for null (with an exception thrown if needed) would be fine or is any other solution? Thanks in advance, Tamas -------------------------- import c.stdio; class xRecord{ int b; this() {b=3;} void set(int x) { if(this==null) { throw new Error("OOOooooppppsss !"); } else { printf("The value of _this_: %p\n",this); } b=x; } } void main(char[][] args) { xRecord xr2; // xr2=new xRecord(); //********************************* printf("start\n"); if(xr2==null) { printf("xr2 is null\n"); } else { printf("xr2 is: %p\n",xr2); } xr2.set(10); // hangs up if xr2 equals to null printf("finish\n"); } -------------------------------- Tamas Nagy MicroWizard Ltd. Hungary
May 05 2002
"MicroWizard" <MicroWizard_member pathlink.com> wrote in message news:ab38mr$2b7d$1 digitaldaemon.com...Should D make any run-time check whether a reference to an object is null or not, before it calls a member function?I would suggest to put it into the same category as the array bounds check. It would be too slow in release builds, but when debugging, error, instead of just "Access Violation at blablabla".
May 05 2002
In article <ab3ak8$2cqj$1 digitaldaemon.com>, Pavel Minayev says..."MicroWizard" <MicroWizard_member pathlink.com> wrote in message news:ab38mr$2b7d$1 digitaldaemon.com...I agree completely. Tamas NagyShould D make any run-time check whether a reference to an object is null or not, before it calls a member function?I would suggest to put it into the same category as the array bounds check. It would be too slow in release builds, but when debugging, error, instead of just "Access Violation at blablabla".
May 05 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:ab3ak8$2cqj$1 digitaldaemon.com..."MicroWizard" <MicroWizard_member pathlink.com> wrote in message news:ab38mr$2b7d$1 digitaldaemon.com...nullShould D make any run-time check whether a reference to an object isAgreed. -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mailor not, before it calls a member function?I would suggest to put it into the same category as the array bounds check. It would be too slow in release builds, but when debugging, error, instead of just "Access Violation at blablabla".
May 05 2002
Is there some distinction in the compiler/libraries between debug and release builds? "Pavel Minayev" <evilone omen.ru> wrote in message news:ab3ak8$2cqj$1 digitaldaemon.com..."MicroWizard" <MicroWizard_member pathlink.com> wrote in message news:ab38mr$2b7d$1 digitaldaemon.com...nullShould D make any run-time check whether a reference to an object isor not, before it calls a member function?I would suggest to put it into the same category as the array bounds check. It would be too slow in release builds, but when debugging, error, instead of just "Access Violation at blablabla".
May 06 2002
"Matthew Wilson" <mwilson nextgengaming.com> wrote in message news:ab7efd$fv9$1 digitaldaemon.com...Is there some distinction in the compiler/libraries between debug and release builds?In release build, compiler removes all assertions, invariant calls and unittests from generated code. It also doesn't perform array bounds checks. As for the library, currently, only debug version exist (with all checks turned on), due to the alpha nature of the compiler. But I guess that, as soon as Walter is sure there are no serious bugs left in there, he'll do a recompile in release mode.
May 06 2002