1

我最近在一次旧考试中阅读了以下 JML 代码:

Class L {
  /*@non_null*/ int[] a;

  /*@ public normal_behaviour
    @ requires !(\exists int i; 0 <= i && i < a.length; a[i] == d);
    @ ensures a.length == \old(a.length) + 1;
    @ ensures a[\old(a.length)] == d;
    @ ensures (\forall int i; 0 <= i && i < \old(a.length);
                  a[i] == \old(a[i]));
    @ assignable a, a[*];
    @*/
  public void st(int d) {
      ...
  }
}

我不明白

assignable a, a[*];

部分。是什么a[*]意思?如果只有

assignable a;

?

(参考链接会很棒。)

4

1 回答 1

1

在以下情况下,assignable 子句JML仅允许修改位置 loc 的方法:

- loc is mentioned in the method’s assignable clause;
- loc is not allocated when the method starts execution; or
- loc is local to the method (i.e., a local variable or a formal parameter)

使用是¹a[*]的简写[0 ... a.length-1];

更多信息| 被引参考文献

于 2015-03-04T06:08:35.193 回答