Thread overview | ||||||
---|---|---|---|---|---|---|
|
December 29, 2013 Do assertions provide a mechanism for subtyping? If not are they composable? | ||||
---|---|---|---|---|
| ||||
D allows inputs and outputs to have assertions placed on them. i.e. int f(int x){ in{ assert(even(x)); } out{ assert(odd(x));; } } I would like to know if D tries to statically check these assertions. If so that would give a subtyping mechanism which would be kind of neat. If not, consider the following scenario in addition to f. int g(int x){ in{ assert(!odd(x)); } ... } Suppose I made a call: g(f(x)); Can this be made to fail by composing the assertions? Are there any tools or support for model checking and/or software verification in D outside of the core language (like Frama-C) that would support such analyses? |
December 29, 2013 Re: Do assertions provide a mechanism for subtyping? If not are they composable? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan | Jonathan:
> I would like to know if D tries to statically check these assertions.
Currently D doesn't statically verify them. I have an enhancement request in the works for something related, but it's not powerful enough for your use case.
Bye,
bearophile
|
January 01, 2014 Re: Do assertions provide a mechanism for subtyping? If not are they composable? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | >, but
> it's not powerful enough for your use case.
>
> Bye,
> bearophile
Is there a link available, so that I could see what is in the making?
|
January 01, 2014 Re: Do assertions provide a mechanism for subtyping? If not are they composable? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan | Jonathan: > Is there a link available, so that I could see what is in the making? Yes, this is two thirds of my proposal: http://www.digitalmars.com/d/archives/digitalmars/D/enum_pre-conditions_217595.html Bye, bearophile |
Copyright © 1999-2021 by the D Language Foundation