5.7.12  Mythryl Conditionals

The Mythryl case statement is essentially identical to that of SML except for the addition of the long longed-for esac terminator:

    case (foo)
    1 => printf "I\n";
    2 => printf "II\n";
    3 => printf "III\n";
    _ => printf "Many!\n";

The Mythryl if statement differs more from that of SML. The then and else clauses comprise implicit code blocks, which in many cases considerably reduces code verbosity. Also, the Mythryl version supplies a terminal fi in honor of the late Dijkstra:

    if  good                           # Conditional parens not needed around lone identifier.
        printf "Very good.\n";
        printf "Yes, very good indeed!\n";
        printf "Not good.\n";
        printf "Doubleplus ungood!\n";

Also, unlike SML, Mythryl allows the else clause to be dropped, in which case its value defaults to Void:

    if  good
        printf "Very good.\n";
        printf "Yes, very good indeed!\n";

In additional to vanilla if, Mythryl also supports a C-flavored trinary conditional expression ... ?? ... :: ...:

    sprintf "%d cow%s" cows (cows > 1 ?? "s" :: "");

Finally, the and and or boolean operators are implemented using short-circuit evaluation, making them implicit conditionals:

    if (f != 0.0
        (1.0 / f) > 2.0      # Cannot throw divide-by-zero exception.
       printf "I feel silly!\n";

Comments and suggestions to: