Declarative languages ββare built from expressions, while imperative languages ββare built from statements.
The usual explanation is what to do and how to do it. You have already found confusion in this. If you do, declarative uses definitions (by name), and imperative uses definitions of definitions. What is a declarative language? One that only calls definitions? If so, then the only Haskell program you could write is for sure main !
There is a declarative way and an imperative way to have branching, and this follows directly from the definition. A declarative branch is an expression, and a mandatory branch is an expression. Haskell has case β¦ of β¦ (expression), and C has if (β¦) {β¦} else {β¦} (instruction).
What is the difference between expressions and statements? Expressions matter, while statements have consequences. What is the difference between values ββand effects?
For expressions, there is a function ΞΌ that maps any expression e to the value ΞΌ(e) . This is also called semantics, or meaning, and ideally represents a well-defined mathematical object. This method of determining values ββis called denotational semantics. There are other methods.
For operators, there is state P immediately before operator S and state Q immediately after. The effect S is a delta from P to Q. This method of determining effects is called Chorus logic. There are other methods.
source share