| Thread overview | ||||||||
|---|---|---|---|---|---|---|---|---|
|
March 05, 2012 The state of contract programming in D | ||||
|---|---|---|---|---|
| ||||
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 | ||||
March 05, 2012 Re: The state of contract programming in D | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Alex Rønne Petersen | 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.
| |||
March 06, 2012 Re: The state of contract programming in D | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Alex Rønne Petersen | 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 !
| |||
March 06, 2012 Re: The state of contract programming in D | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | 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 | |||
March 06, 2012 Re: The state of contract programming in D | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Alex Rønne Petersen | 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. | |||
March 06, 2012 Re: The state of contract programming in D | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | 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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply