Skip to content

If-Then-Else Syntax support #44

@tmarsteel

Description

@tmarsteel

If-Then-Else Logic is already supported with this "syntax":

?- once((If, Then) ; Else).

The official syntax, used by other prologs, and that must be implemented with this ticket however is

?- (If -> Then ; Else)

The trick is that with iso operators, this is parsed as ';'('->'(If, Then), Else). ->/2 is then probably defined like

'->'(If, Then) :-
  call(If),
  (Then ; !).

With ! being basically impossible to implement into the coroutine-based search tree, implementing this syntax on ISO operators seems pretty challenging.
One option could be redefining the operators so (If -> Then ; Else) gets parsed as '->'(If, ';'(Then, Else)) and implementing '->'/2 using once.

If it is not possible/feasible to implement this way, consider an alternate syntax that is more readable than the once version, e.g. if(IF) then (Then) else (Else)

Metadata

Metadata

Assignees

No one assigned

    Labels

    usabilityMakes behaviour and outputs of the system easier to understand.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions