Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why use the colon before the type in a VAR declaration, and why have the vertical bar as a case separator rather than a semicolon?

0
Posted

Why use the colon before the type in a VAR declaration, and why have the vertical bar as a case separator rather than a semicolon?

0

A. These are both “syntactic sugar” to help the compiler know what it’s doing. For instance, if there were no colon in a type declaration, the compiler would not know the last identifier is supposed to be a type name because it wouldn’t know it was last until checking the next token. Lookaheads are expensive. Also, there was no need for subsequent committees and designers to change this from Wirth’s definition. After all, there is no ambiguity here.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123