mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fix example assert macro to make it more flexible
The previous version only optimized away the condition if it was side-effect-free, which borders on inadmissible. Fixed. This new version also accepts any valid condition in LSL, not just an integer one but also float, key, list, string... so for example these are valid now: assert(my_key_var); assert([1, 2, 3]); assert(PI); assert(llSetPos(pos));
This commit is contained in:
parent
0bd5c0881c
commit
9f03c468f7
1 changed files with 2 additions and 2 deletions
|
@ -364,8 +364,8 @@ but this will cause an error:
|
|||
|
||||
<p>This enables using many preprocessor tricks, like creating an <code>assert()</code> macro similar to that in C:</p>
|
||||
|
||||
<pre><code>#define assert(x) do { if (DEBUG && !(x)) \
|
||||
llOwnerSay("ASSERTION FAILED: " #x); } while (0)
|
||||
<pre><code>#define assert(...) do { if (DEBUG) if (__VA_ARGS__) ; \
|
||||
else llOwnerSay("ASSERTION FAILED: " #__VA_ARGS__); } while (0)
|
||||
</code></pre>
|
||||
|
||||
<p>without worrying about the extra memory that it will take in production code once DEBUG is switched off, or about the loop taking up actual code memory.</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue