Ghost fields for Contract Programming

2010-10-09 Thread bearophile
A possible enhancement for Contract Programming: http://d.puremagic.com/issues/show_bug.cgi?id=5027 This is not meant as a replacement for "old" (that allows to refer to the state at the entry to the instance method). Bye, bearophile

Re: Ghost fields for Contract Programming

2010-10-09 Thread Tomek Sowiński
bearophile napisał: > The ghost fields may be used to store partial computations useful to reduce > the work done by the class invariant. You can do: class C { version(unittest) int temp; invariant() { // use temp } } Or am I missing something? -- Tomek

Re: Ghost fields for Contract Programming

2010-10-09 Thread bearophile
Tomek S.: > You can do: > > class C { > version(unittest) int temp; > invariant() { > // use temp > } > } > > Or am I missing something? D2 has several ways to perform conditional compilation, so you may implement hand-made ghost fields using a version(debug). And ghost fields are ve

Re: Ghost fields for Contract Programming

2010-10-09 Thread Denis Koroskin
On Sat, 09 Oct 2010 23:51:44 +0400, Tomek Sowiński wrote: bearophile napisał: The ghost fields may be used to store partial computations useful to reduce the work done by the class invariant. You can do: class C { version(unittest) int temp; invariant() { // use temp } } Or am

Re: Ghost fields for Contract Programming

2010-10-09 Thread bearophile
> And ghost fields are very important to start with (I was not sure to submit > an enhancement request). Sorry, I meant, 'And ghost fields aren't very important to start with'. Bye, bearophile

Re: Ghost fields for Contract Programming

2010-10-09 Thread Tomek Sowiński
bearophile napisał: > Tomek S.: > >> You can do: >> >> class C { >> version(unittest) int temp; >> invariant() { >> // use temp >> } >> } >> >> Or am I missing something? > > D2 has several ways to perform conditional compilation, so you may > implement hand-made ghost fields using a