top | item 41176065

(no title)

TurningCanadian | 1 year ago

instead of "expression" you meant "exception", right?

discuss

order

Jtsummers|1 year ago

In the statement/expression-oriented axis of languages, Go is a statement oriented language (like C, Pascal, Ada, lots of others). This is in contrast to expression oriented languages like the Lisp family, most, if not all, functional languages, Ruby, Smalltalk and some others.

Expressions produce a value, statements do not. That's the key distinction. In C, if statements do not produce a value. In Lisp, if expressions do. This changes where the expression/statement is able to be used and, consequently, how you might construct programs.

runevault|1 year ago

A simple example for anyone who might not appreciate why this can be so nice.

In languages where if is a statement (aka returns no value), you'd write code like

int value;

if(condition) { value = 5; } else { value = 10; }

Instead of just int value = if(condition) {5} else {10}

Some languages leave ifs as statements but add trinary as a way to get the same effect which is an acceptable workaround, but at least for me there are times I appreciate an if statement because it stands out more making it obvious what I'm doing.

whalesalad|1 year ago

expression as-in s-expression (ex: lisp)