Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 08, 2010 use of Class Invariants | ||||
---|---|---|---|---|
| ||||
At the moment most of my public member functions are littered with these kind of in-out clauses. in{ assert(wellformed, toString); } out{ assert(wellformed, toString); } They just beg for invariants, I though.. But invariants don't report the location of failure of contract, only the location of failure within the invariant. This seems kind of limiting. Am I missing something here? |
December 08, 2010 Re: use of Class Invariants | ||||
---|---|---|---|---|
| ||||
Posted in reply to %u | On Wednesday 08 December 2010 00:22:23 %u wrote:
> At the moment most of my public member functions are littered with these kind of in-out clauses.
>
> in{
> assert(wellformed, toString);
> }
> out{
> assert(wellformed, toString);
> }
>
> They just beg for invariants, I though..
> But invariants don't report the location of failure of contract, only the
> location of failure within the invariant.
> This seems kind of limiting. Am I missing something here?
If an invariant fails, it throws an AssertError which will give you stack trace. That stack trace should include which function called the invariant. So, it _does_ tell you which function resulted in the invariant failing.
- Jonathan M Davis
|
December 08, 2010 Re: use of Class Invariants | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | == Quote from Jonathan M Davis (jmdavisProg@gmx.com)'s article
> On Wednesday 08 December 2010 00:22:23 %u wrote:
> > At the moment most of my public member functions are littered with these kind of in-out clauses.
> >
> > in{
> > assert(wellformed, toString);
> > }
> > out{
> > assert(wellformed, toString);
> > }
> >
> > They just beg for invariants, I though..
> > But invariants don't report the location of failure of contract, only the
> > location of failure within the invariant.
> > This seems kind of limiting. Am I missing something here?
> If an invariant fails, it throws an AssertError which will give you stack trace.
> That stack trace should include which function called the invariant. So, it
> _does_ tell you which function resulted in the invariant failing.
> - Jonathan M Davis
That is what I am missing, a stack trace.
How do I see a stack trace? dmd1(win)
|
December 08, 2010 Re: use of Class Invariants | ||||
---|---|---|---|---|
| ||||
Posted in reply to %u | %u Wrote:
> That is what I am missing, a stack trace.
> How do I see a stack trace? dmd1(win)
I don't think the Windows stack trace is compete yet. Works in Linux.
|
December 08, 2010 Re: use of Class Invariants | ||||
---|---|---|---|---|
| ||||
Posted in reply to %u | > That is what I am missing, a stack trace. > How do I see a stack trace? dmd1(win) Well tango includes stack traces if you import the right module. For D2/Win use http://3d.benjamin-thaut.de/?p=15 |
Copyright © 1999-2021 by the D Language Foundation