In some situations (e.g. debugging) it may be nice to trigger an error unconditionally. The following will not work since error is not possible without else:

While(exp, _):-
	error "Error" on exp

Therefore, I expected the following TS code to do the job:

While(exp, _):-
	where false
	else error "Error" on exp

But false doesn’t fail, therefore the error is not displayed.


A workaround is to instead use a condition that is known to be false.

While(exp, _):-
	where exp == "xxxxxxxxx"
	else error "Error" on exp
Submitted by D. Pelsmaeker on 19 June 2014 at 12:03

Log in to post comments