digitalmars.D - No TypeTuple expansion for assert?
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (16/16) Oct 03 2014 I know that assert is not a function but it would be nice to have.
- Dmitry Olshansky (5/21) Oct 03 2014 Indeed. If we make it a function and put in object.d would anyone notice...
- monarch_dodra (4/10) Oct 03 2014 I think there are semantics that prevent that. Such as
- H. S. Teoh via Digitalmars-d (11/22) Oct 03 2014 void assert(lazy bool exp) {
- monarch_dodra (5/32) Oct 04 2014 There might still be an issue in regards to linking though: I
- Timon Gehr (3/19) Oct 04 2014 It should just auto-expand. There is no reason for it not to. Same for
I know that assert is not a function but it would be nice to have. import std.exception; void foo(T...)(T args) { // Compiles: enforce(args); // DOES NOT COMPILE: // assert(args); // Must expand manually: assert(args[0], args[1]); } void main() { foo(true, "hi"); } Ali
Oct 03 2014
03-Oct-2014 23:08, Ali Çehreli пишет:I know that assert is not a function but it would be nice to have.Indeed. If we make it a function and put in object.d would anyone notice the change?import std.exception; void foo(T...)(T args) { // Compiles: enforce(args); // DOES NOT COMPILE: // assert(args); // Must expand manually: assert(args[0], args[1]); } void main() { foo(true, "hi"); } Ali-- Dmitry Olshansky
Oct 03 2014
On Friday, 3 October 2014 at 19:21:38 UTC, Dmitry Olshansky wrote:03-Oct-2014 23:08, Ali Çehreli пишет:I think there are semantics that prevent that. Such as "assert(0)", or removing the evaluation of arg in "assert(arg())" altogether in release.I know that assert is not a function but it would be nice to have.Indeed. If we make it a function and put in object.d would anyone notice the change?
Oct 03 2014
On Fri, Oct 03, 2014 at 08:02:14PM +0000, monarch_dodra via Digitalmars-d wrote:On Friday, 3 October 2014 at 19:21:38 UTC, Dmitry Olshansky wrote:void assert(lazy bool exp) { version(assert) // (!) if (!exp) __fatal_runtime_error(); } Doesn't work for assert(0); but does work for not evaluating the argument in release build. (Yeah I know, implementation of 'lazy' leaves a lot to be desired, but hey, that can be argued to be a QOI issue.) T -- This is not a sentence.03-Oct-2014 23:08, Ali Çehreli пишет:I think there are semantics that prevent that. Such as "assert(0)", or removing the evaluation of arg in "assert(arg())" altogether in release.I know that assert is not a function but it would be nice to have.Indeed. If we make it a function and put in object.d would anyone notice the change?
Oct 03 2014
On Friday, 3 October 2014 at 20:28:21 UTC, H. S. Teoh via Digitalmars-d wrote:On Fri, Oct 03, 2014 at 08:02:14PM +0000, monarch_dodra via Digitalmars-d wrote:There might still be an issue in regards to linking though: I have some code where assert-only functions are only defined for non-release.On Friday, 3 October 2014 at 19:21:38 UTC, Dmitry Olshansky wrote:void assert(lazy bool exp) { version(assert) // (!) if (!exp) __fatal_runtime_error(); } Doesn't work for assert(0); but does work for not evaluating the argument in release build. (Yeah I know, implementation of 'lazy' leaves a lot to be desired, but hey, that can be argued to be a QOI issue.) T03-Oct-2014 23:08, Ali Çehreli пишет:I think there are semantics that prevent that. Such as "assert(0)", or removing the evaluation of arg in "assert(arg())" altogether in release.I know that assert is not a function but it would be nice to have.Indeed. If we make it a function and put in object.d would anyone notice the change?
Oct 04 2014
On 10/03/2014 09:08 PM, Ali Çehreli wrote:I know that assert is not a function but it would be nice to have. import std.exception; void foo(T...)(T args) { // Compiles: enforce(args); // DOES NOT COMPILE: // assert(args); // Must expand manually: assert(args[0], args[1]); } void main() { foo(true, "hi"); } AliIt should just auto-expand. There is no reason for it not to. Same for static assert.
Oct 04 2014