xtodo

xtodo

Intertwined Relation of Syntax and Semantics

This is a example of intertwined relation of syntax and semantics.

let's dive into detail.

in programing languages, you have statements and expressions.

For example, in python, to specify branch control, you have if-statement. But you do not have if-expression.

In JavaScript, you have both if-statement (e.g. if (x === 1) { f() } else { g() } ) and if-expression. (e.g. (( x === 1 ) ? f() : g() ))

Are the difference of statements vs expressions, a semantic issue? Yes. Because their meaning is different. One is procedure, the other return a value (besides also is procedure).

now, similarly, in many programing languages, a function can be defined by a statement and or by an expression. e.g. in JavaScript, use keyword function at top level to define function via statement, and you can also use JS: Arrow Function e.g. (x => x + 1) to define function as expression. it returns the function as a value.

in python, you use def statement to define a function. or you can use lambda, it is an expression.

one advantage of function expression in programing language is that it is convenience to embed it inside another expression.

but python's indentation syntax, requires complicated expression to be multiple lines, because not all basic semantics of python can be expressed as expression, such as the conditional if.

so with you use the lambda function expression, and if it requires a if conditional, it must be multiple lines of the indentation syntax.

this indentation syntax, prevents the embedding or nesting of arbitrary expressions.

xtodo

where is textedit untitled saved

~/Library/Containers/com.apple.TextEdit/Data/Library/Autosave Information/

xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xah coprographia unix culture 2022-12-26 vjBPY
xah coprographia unix culture 2022-12-26 vjBPY
xtodo

writing twitter bot

xahweb user facing

xahweb, less important

old