Page 1 of 1

IMPLIES via IF THEN

Posted: Sun Dec 16, 2018 7:28 am
by drago
Hi,
I suggest adding IMPLIES keyword to the language (having EQUIV but not IMPLIES is strange) and/or adding the following IF-THEN >>Boolean expression<< simple forms (default ELSE to TRUE in case q is Boolean):
IF p THEN q =
IF p THEN q END IF =
IF p THEN q ELSE true END IF

(the need for the trailing "ELSE true END IF" is really unnecessary if we just want IMPLIES and in Boolean expressions we almost always do).

Having those simple forms we define:
p IMPLIES q = IF p THEN q

Here is an example.

Current syntax:
AND (P, IF color = 'Red' THEN city = 'London' ELSE true END IF)

Proposed syntax:
AND (P, IF color = 'Red' THEN city = 'London')
or
AND (P, color = 'Red' IMPLIES city = 'London')

----

Similarly, CASE WHEN-THEN could have a simple/default form when q is Boolean:
CASE WHEN p THEN q =
CASE WHEN p THEN q END CASE =
CASE WHEN p THEN q ELSE true END CASE

Having those simple forms we define:
p IMPLIES q = IF p THEN q = CASE WHEN p THEN q

Current syntax of the example:
AND (P, CASE WHEN color = 'Red' THEN city = 'London' ELSE true END CASE)

Proposed syntax:
AND (P, CASE WHEN color = 'Red' THEN city = 'London')
or
AND (P, color = 'Red' IMPLIES city = 'London')

Re: IMPLIES via IF THEN

Posted: Sun Dec 16, 2018 9:59 pm
by Dave
The trailing END IF, END CASE, or just END is needed to disambiguate the end of the conditional subexpression from the remainder of the expression.