www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - The state of contract programming in D

reply =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
Hi,

What with D's contract programming getting publicity, I think it's high 
time we made the implementation match the documentation (and TDPL).

Just a 'few' contract-related issues:

* http://d.puremagic.com/issues/show_bug.cgi?id=6857
* http://d.puremagic.com/issues/show_bug.cgi?id=7584
* http://d.puremagic.com/issues/show_bug.cgi?id=6549
* http://d.puremagic.com/issues/show_bug.cgi?id=6856
* http://d.puremagic.com/issues/show_bug.cgi?id=7337
* http://d.puremagic.com/issues/show_bug.cgi?id=5039
* http://d.puremagic.com/issues/show_bug.cgi?id=7517
* http://d.puremagic.com/issues/show_bug.cgi?id=519

More subtle issues:

* http://d.puremagic.com/issues/show_bug.cgi?id=2350
* http://d.puremagic.com/issues/show_bug.cgi?id=4995

Syntactical issues/enhancements:

* http://d.puremagic.com/issues/show_bug.cgi?id=6415
* http://d.puremagic.com/issues/show_bug.cgi?id=5038
* http://d.puremagic.com/issues/show_bug.cgi?id=6453

The issues I personally see as most important are related to contract 
inheritance and contracts on functions without a body.

Additionally, I think that dropping the need for parentheses on 
invariant declarations would be a good idea, such that it feels more 
like unittest declarations. Furthermore, the ability to declare multiple 
invariants is essential for mixins and meta-programming in general.

(Many of the issues have pull requests pending review.)

Thoughts? I think we need to figure out most of these before 2.059...

-- 
- Alex
Mar 04 2012
next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
On 05/03/2012 04:26, Alex Rønne Petersen wrote:
<snip>
 Additionally, I think that dropping the need for parentheses on invariant
declarations
 would be a good idea, such that it feels more like unittest declarations.
<snip> It can't be done at the moment, because invariant is also the old name for immutable. Indeed, the brackets were introduced to distinguish between the two meanings, though it would have been better to introduce a new keyword in the first place rather than create a new meaning of invariant that required a change to existing syntax. Stewart.
Mar 05 2012
parent reply =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
On 05-03-2012 11:46, Stewart Gordon wrote:
 On 05/03/2012 04:26, Alex Rønne Petersen wrote:
 <snip>
 Additionally, I think that dropping the need for parentheses on
 invariant declarations
 would be a good idea, such that it feels more like unittest declarations.
<snip> It can't be done at the moment, because invariant is also the old name for immutable. Indeed, the brackets were introduced to distinguish between the two meanings, though it would have been better to introduce a new keyword in the first place rather than create a new meaning of invariant that required a change to existing syntax. Stewart.
Shouldn't invariant as a type modifier be deprecated once and for all? I mean, immutable has existed for a long time now... Also, just so we're on the same page here, you mean the parentheses, right? If so, I'm not sure I quite understand where the problem arises. Could you elaborate? Thanks! -- - Alex
Mar 06 2012
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
On 06/03/2012 15:19, Alex Rønne Petersen wrote:
<snip>
 Shouldn't invariant as a type modifier be deprecated once and for all? I mean,
immutable
 has existed for a long time now...
It already is deprecated. Download a current DMD version and see for yourself. But how does this help? The ambiguity isn't gone until this use of invariant is removed from the language/compiler completely.
 Also, just so we're on the same page here, you mean the parentheses, right? If
so, I'm not
 sure I quite understand where the problem arises. Could you elaborate?
invariant { int id; char[] name; } Is this a block of class-level invariant member declarations, or a class invariant that does nothing but declare two local variables? Since D2's early days it has dealt with it by using invariant() for the latter. Stewart.
Mar 06 2012
parent =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
On 06-03-2012 16:44, Stewart Gordon wrote:
 On 06/03/2012 15:19, Alex Rønne Petersen wrote:
 <snip>
 Shouldn't invariant as a type modifier be deprecated once and for all?
 I mean, immutable
 has existed for a long time now...
It already is deprecated. Download a current DMD version and see for yourself. But how does this help? The ambiguity isn't gone until this use of invariant is removed from the language/compiler completely.
To clarify: I meant remove the feature entirely.
 Also, just so we're on the same page here, you mean the parentheses,
 right? If so, I'm not
 sure I quite understand where the problem arises. Could you elaborate?
invariant { int id; char[] name; } Is this a block of class-level invariant member declarations, or a class invariant that does nothing but declare two local variables? Since D2's early days it has dealt with it by using invariant() for the latter. Stewart.
I totally didn't think of that. Thanks! I wonder if we have any plans for when invariant as a type modifier will be removed entirely... -- - Alex
Mar 06 2012
prev sibling parent deadalnix <deadalnix gmail.com> writes:
Le 05/03/2012 05:26, Alex Rønne Petersen a écrit :
 The issues I personally see as most important are related to contract
 inheritance and contracts on functions without a body.

 Additionally, I think that dropping the need for parentheses on
 invariant declarations would be a good idea, such that it feels more
 like unittest declarations. Furthermore, the ability to declare multiple
 invariants is essential for mixins and meta-programming in general.
100% agreed !
Mar 06 2012