Date: Thu, 23 Sep 2021 11:39:30 -0400
On Wed, Sep 22, 2021 at 3:41 PM Gašper Ažman via SG21 <sg21_at_[hidden]>
wrote:
> Personally I'm not married to the current grammar, but we do need a
> plausible alternative, and we need it soon.
>
> An alternative syntax needs to have:
> - an obvious terminator (a comma is not that, especially for assert)
> - somewhere to do the preamble (pre:, post r:, assert: )
> - not be current valid syntax.
>
> Thinking out loud here, but could braces work?
>
In many ways braces are better, or maybe required to be married with a
colon, because currently a colon too often means "doesn't terminate" or
"isn't terminated until you see another one"
case 100:
isn_t();
terminated();
case 200:
still_also();
case_100();
label:
no();
end();
in();
sight();
Particularly in class scope:
private:
void this_is_private();
void so_is_this();
...
public:
void no_longer_private();
invariant:
x < 10; // is this a public invariant??? Is public terminated? Are
they at all related?
void some_function(); // is this an invariant???
> auto f(auto const x, int const y) noexcept -> void
> requires integral<decltype(x)>
> pre {
> x > 0;
> y > x;
> }
> pre(axiom) {
> {x % 2 == 0};
> }
> post(audit, new) [r=return, x, y] { // seems like lambda-like
> captures fit in
> {r % x == 0};
> {r % y == 0};
> }
> {
> /* function body */
> assert {
> { x > 0 };
> };
> }
>
> That looks pretty much like the grammar for the "requires" expression
> except with runtime values. Hm.....
>
Completely. There are lots of similarities between requires/concepts and
contracts. Maybe we should stop ignoring them.
wrote:
> Personally I'm not married to the current grammar, but we do need a
> plausible alternative, and we need it soon.
>
> An alternative syntax needs to have:
> - an obvious terminator (a comma is not that, especially for assert)
> - somewhere to do the preamble (pre:, post r:, assert: )
> - not be current valid syntax.
>
> Thinking out loud here, but could braces work?
>
In many ways braces are better, or maybe required to be married with a
colon, because currently a colon too often means "doesn't terminate" or
"isn't terminated until you see another one"
case 100:
isn_t();
terminated();
case 200:
still_also();
case_100();
label:
no();
end();
in();
sight();
Particularly in class scope:
private:
void this_is_private();
void so_is_this();
...
public:
void no_longer_private();
invariant:
x < 10; // is this a public invariant??? Is public terminated? Are
they at all related?
void some_function(); // is this an invariant???
> auto f(auto const x, int const y) noexcept -> void
> requires integral<decltype(x)>
> pre {
> x > 0;
> y > x;
> }
> pre(axiom) {
> {x % 2 == 0};
> }
> post(audit, new) [r=return, x, y] { // seems like lambda-like
> captures fit in
> {r % x == 0};
> {r % y == 0};
> }
> {
> /* function body */
> assert {
> { x > 0 };
> };
> }
>
> That looks pretty much like the grammar for the "requires" expression
> except with runtime values. Hm.....
>
Completely. There are lots of similarities between requires/concepts and
contracts. Maybe we should stop ignoring them.
-- Be seeing you, Tony
Received on 2021-09-23 10:39:44