gmic
gmic copied to clipboard
New math parser function idea: check()
I tried doing everything in one go with check instead of check + eval combo, but apparently, it does not support const. So, I decided to suggest a idea of check() which acts like math parser version of check command. Here's a real-world application:
failed=1;
eval "
# snipped code
condition?(
set('failed',0;);
# snipped code
);"
if $failed error inv_inp fi
This also could be in the form of check and then eval without needing set(). So, you have to have two sections for one thing.
With check(), it looks simpler:
eval "
# snipped code
check(condition);
# snipped code
check() returns 1, or throws a error when it doesn't meet criteria. Personally, I would do this.
The main reason for doing this is not having to copy code, which in one of my case is copying a ${2--1} twice.