Seeking more verbose syntax, e.g. "Then" -> ","

This still requires some commata and also additional brackets, but it might be somewhat more legible.

Then /: If[cond_, Then[x_], Else[y_]] := If[cond, x, y]
Then /: If[cond_, Then[x_]] := If[cond, x]

To be used like this:

If[
 True,
 Then[
  Print["True!"]
  ],
 Else[
  Print["Not True!"]
  ]
 ]

The reason why I use TagSetDelayed instead of SetDelayed here is that If, as a built-in symbol, is projected. In general, it is good practice not to unprotect and modify built-in symbols (but as all good advice, this has certainly also exceptions). Using Then /: If[...] := ... assigns the definition (more precisely, the rule) to Then which is not protected. That's it.

I am not sure whether this is necessary, but things might become more robust by giving Then and Else the attribute HoldAll.

SetAttributes[Then, HoldAll];
SetAttributes[Else, HoldAll];

I think the Notation package should be able to do this, but I don't think you need to use it. Instead, create the following InputAliases:

CurrentValue[EvaluationNotebook[],{InputAliases,"then"}] = TemplateBox[
    {},
    "Then",
    DisplayFunction->(StyleBox[" Then",ShowAutoStyles->False, FontColor->GrayLevel[.5]]&),
    InterpretationFunction->(","&),
    SyntaxForm->","
];
CurrentValue[EvaluationNotebook[],{InputAliases,"else"}] = TemplateBox[
    {},
    "Else",
    DisplayFunction->(StyleBox[" Else",ShowAutoStyles->False, FontColor->GrayLevel[.5]]&),
    InterpretationFunction->(","&),
    SyntaxForm->","
];

Then, just use the aliases instead of commas. For example:

If[x>3 Then y = 1; z = 2 Else y = 10; z = 20]

If[x > 3, y = 1; z = 2, y = 10; z = 20]

If you really want to evaluate an If construct, and have it displayed using the "Then" and "Else" tokens, then you would need to use the Notation package. But, I think you want to be able to visually parse code that you've written better, so the package shouldn't be needed.


Trying to introduce new notation could very easily lead to errors. I think it's not a good idea.

You can make the code more readable using line breaks, indentation and comments.

Example 1

If[condition,
  foo;
  bar;
  baz
  ,
  boo;
  hoo
]

Example 2

If[
    condition
    ,
    foo;
    bar;
    baz
    ,
    boo;
    hoo
]

Example 3

If[
    condition
    , (* then *)
    foo;
    bar;
    baz
    , (* else *)
    boo;
    hoo
]

(Without claiming that mine is a good style, I'd like to show it. While I prefer concise formatting, I still use plenty of indentation and line breaks.)