Re: Design by Contract
| From: | Joe Watkins | Date: | Wed, 11 Feb 2015 08:29:12 +0000 |
| Subject: | Re: Design by Contract | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82458@lists.php.net to get a copy of this message | ||
> http://dlang.org/deprecate.html#invariant as an alias for
> immutable
It's not an alias, the most recent compiler emits an error if you try to
use invariant contracts, and immutable isn't a kind of contract.
immutable is a property modifier:
immutable: http://dpaste.dzfl.pl/7e724b599640
invariant (won't compile using latest release):
http://dpaste.dzfl.pl/102c5c5adef5
> Isn't invariant good enough?
Good enough for us, yeah.
Cheers
Joe
On Wed, Feb 11, 2015 at 8:18 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> Hi Joe,
>
> On Wed, Feb 11, 2015 at 5:02 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
>
>> On Wed, Feb 11, 2015 at 4:54 PM, Joe Watkins <pthreads@pthreads.org>
>> wrote:
>>
>>> So it turns out that invariant is already deprecated in D, they have
>>> dropped it in favour of immutable properties.
>>>
>>> I guess I'll have to install an old version, or try to extract
>>> everything we need from their obviously outdated documentation ...
>>>
>>
>> That's too bad.
>> Eiffel uses invariant.
>>
>>
>> https://docs.eiffel.com/book/method/et-design-contract-tm-assertions-and-exceptions
>>
>
> http://dlang.org/deprecate.html#invariant as an alias for
> immutable
>
> I think D folks would like to be more strict. Object is great, but state
> management can be complex.
> I like immutable also since it prevents modification by mistake. I'm not
> sure if we should go for it
> without having invariant. Even if we have invariant, we may have immutable
> object/scalar in the future.
> Both are good.
>
> Isn't invariant good enough? I don't think Eiffel will drop invariant
> support in favor of immutables.
>
> Regards,
>
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net
>