gmic icon indicating copy to clipboard operation
gmic copied to clipboard

New math parser function idea: check()

Open Reptorian1125 opened this issue 4 months ago • 2 comments

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.

Reptorian1125 avatar Sep 28 '24 15:09 Reptorian1125