Topic: assert specifications on functions


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Mon, 21 Jul 2014 10:00:08 -0700 (PDT)
Raw View
------=_Part_29_276610216.1405962008984
Content-Type: text/plain; charset=UTF-8

What if you could do something like this:

void foo(int x, float y, double z) static_assert( x > 0) assert(y < z);

The static_assert would trigger a compile time error anytime the compiler
can prove that x > 0 in a compile time context. You can also call constexpr
functions on x. This also serves to document the interface pre and post
conditions within the code itself and thus be used for testing. Less
comments required to specify an interface.

The assert() would add a compile time and a runtime check (which calls the
assert() macro)

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_29_276610216.1405962008984
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">What if you could do something like this:<div><br></div><d=
iv>void foo(int x, float y, double z) static_assert( x &gt; 0) assert(y &lt=
; z);&nbsp;</div><div><br></div><div>The static_assert would trigger a comp=
ile time error anytime the compiler can prove that x &gt; 0 in a compile ti=
me context. You can also call constexpr functions on x. This also serves to=
 document the interface pre and post conditions within the code itself and =
thus be used for testing. Less comments required to specify an interface.</=
div><div><br></div><div>The assert() would add a compile time and a runtime=
 check (which calls the assert() macro)</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_29_276610216.1405962008984--

.


Author: "dgutson ." <danielgutson@gmail.com>
Date: Mon, 21 Jul 2014 21:41:20 -0300
Raw View
FWIW,

   me and some colleagues are working in an axiomatic systems proposal
that includes the use case you are proposing. For example, we can
check (at compile time) whether a function can or cannot be called
from a given thread, or whether a function can be called with a mutex
locked.
If you are interested, write me an email to see if we can do something toge=
ther.

FYI, you may want to read some Gabriel Dos Reis' work on axiomatic systems.

  Daniel.

On Mon, Jul 21, 2014 at 2:00 PM, Matthew Fioravante
<fmatthew5876@gmail.com> wrote:
> What if you could do something like this:
>
> void foo(int x, float y, double z) static_assert( x > 0) assert(y < z);
>
> The static_assert would trigger a compile time error anytime the compiler
> can prove that x > 0 in a compile time context. You can also call constex=
pr
> functions on x. This also serves to document the interface pre and post
> conditions within the code itself and thus be used for testing. Less
> comments required to specify an interface.
>
> The assert() would add a compile time and a runtime check (which calls th=
e
> assert() macro)
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.



--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.