Re: assert in EUPHORIA

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...
DerekParnell said...

Although this will perform the testing correctly, it misses out on a couple of the useful aspects of the 'assert' concept.

  1. It always executes the test. The assert is intended to only execute the test during the development phase of the application.

That is what I was going to say about your assert.e; although it may not actually test whether x is 0 when "switched off", it will still calculate x, which may be expensive.

Regards, Pete

I can see the benefit of Shawn's idea of using a type for assertion here: when you're translating, the side-effectless type-check call is removed entirely...

DerekParnell said...

I see your point. The only way around that at the moment is to code ...

ifdef assert then assert(x) end ifdef 

This is a bit more cumbersome but if you really need it then you can do it.

Alternatively, you can use a preprocessor with 4.0's builtin preprocessor ability to expand all assert() calls into the longer ifdef'd form. The code will run with or without it, but with the preprocessor the full advantage of assert() comes.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu