[Issue 1228] Class invariants should not be called before the object is fully constructed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 12 02:11:28 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1228





------- Comment #3 from onlystupidspamhere at yahoo.se  2007-05-12 04:11 -------
(In reply to comment #2)
> Sound reasonable to me, too. You can always refactor to:
> 
> class foo {
> 
>          this() {
>                  Stdout("entering constructor").newline;
>                  barInternal();
>                  Stdout("leaving constructor").newline;
>          }
> 
>          void bar() {
>                  barInternal();
>          }
> 
>         private void barInternal() {
>                 Stdout("method bar()").newline;
>         }
> 
>          invariant {
>                  Stdout("invariant").newline;
>          }
> }

This slows down the release build since at least DMD doesn't inline member
functions. Yes, this is a design decision and I'm not sure which one is better.


-- 



More information about the Digitalmars-d-bugs mailing list