(continuing a thread from D.learn)
Eiffel supports an 'old' construct in post-conditions. For example, an
Add method of a Bag class (generic collection container) might verify
that exactly one element was added to the collection, not zero and not
more than one:
Add(newItem : T) is
Davidson Corry:
> (continuing a thread from D.learn)
I think you have written this post in digitalmars.D in a moment when the
limited brain power is busy with lot of other things :-)
I'd like some form of prestate to be implemented in D2. Usually I use manually
managed ghost variables (in
On 10/26/2011 5:19 PM, bearophile wrote:
out(result, X preX = exprX, Y preY = exprY) { //<== prestate
I'd like something lighter, syntax-wise, where the is no need to state new and
old names and types:
>out(result, exprX, exprY) {
And then the compiler lets you access in the
On 10/27/2011 07:58 AM, Davidson Corry wrote:
On 10/26/2011 5:19 PM, bearophile wrote:
out(result, X preX = exprX, Y preY = exprY) { //<== prestate
I'd like something lighter, syntax-wise, where the is no need to state
new and old names and types:
> out(result, exprX, exprY) {
And then the c
> out(result, exprX, exprY) {
If you don't need to use the method result too, then you probably write
something like:
out(_, exprX, exprY) {
If the method is void then the _ has no value. Is this possible and good?
Bye,
bearophile
On 10/27/2011 11:34 AM, bearophile wrote:
out(result, exprX, exprY) {
If you don't need to use the method result too, then you probably write
something like:
out(_, exprX, exprY) {
If the method is void then the _ has no value. Is this possible and good?
Bye,
bearophile
This is possible,
Oooh! Now we're getting somewhere! You and bearophile have opened my eyes.
On 10/27/2011 1:17 AM, Timon Gehr wrote:
> ...your example shows an extreme case and from that you
> conclude a general statement. That almost never works.
I merely intended to show that my proposed syntax could *handle*
On 10/27/2011 10:02 PM, Davidson Corry wrote:
Oooh! Now we're getting somewhere! You and bearophile have opened my eyes.
On 10/27/2011 1:17 AM, Timon Gehr wrote:
> ...your example shows an extreme case and from that you
> conclude a general statement. That almost never works.
I merely intende
I want to point out (quick, before someone else does!) that the
lowerings I have suggested for old! elsewhere in this thread are naïve.
In the presence of inheritance, interface contracts, and/or multiple
subtyping, things can get notably trickier.
That said,
1) I don't think it affects the ut
On 10/27/2011 2:12 PM, Timon Gehr wrote:
Yes, this design has indeed a keyword-issue that your proposal has not.
I am all for not making it a keyword. The 'body' keyword imho should be
removed too, there is only one place in the grammar where it is ever
needed (and there it is completely redundan
Davidson Corry:
> Agreed. In fact, it occurred to me the other day that we could write
> contracts as
>
> void foo(T t)
> {
> scope(in) {
> // pre-condition contracts
> }
> scope(out) {
> // post-condition contracts
> }
>
Davidson Corry wrote:
> On 10/27/2011 2:12 PM, Timon Gehr wrote:
>> Yes, this design has indeed a keyword-issue that your proposal has not.
>> I am all for not making it a keyword. The 'body' keyword imho should be
>> removed too, there is only one place in the grammar where it is ever
>> needed (
On 10/27/2011 9:04 PM, bearophile wrote:
> Agreed. In fact, it occurred to me the other day that we could write
> contracts as
>
>void foo(T t)
>{
>scope(in) {
> // pre-condition contracts
>}
>scope(out) {
> //
On 10/28/2011 5:10 AM, kennytm wrote:
Davidson Corry wrote:
> ...it occurred to me the other day that we could write contracts as
>
> void foo(T t)
> {
> scope(in) {
>// pre-condition contracts
> }
> scope(out) {
>// pos
Davidson Corry:
> The only reason to have an 'out(result)' form is to declare that we
> intend to use the magic 'result' symbol in the post-condition testing.
This is not true. Currently 'result' has nothing magic, it's just a variable
name, you are free to change it:
int result;
int foo(int
On 10/29/2011 8:26 PM, bearophile wrote:
The only reason to have an 'out(result)' form is to declare that we
intend to use the magic 'result' symbol in the post-condition testing.
This is not true. Currently 'result' has nothing magic, it's just a variable
name, you are free to change it:
Ah
16 matches
Mail list logo