Skip to content

Commit

Permalink
Update chapters/lexicalstructure.tex
Browse files Browse the repository at this point in the history
  • Loading branch information
casella committed Nov 9, 2022
1 parent 2c817dd commit 942776f
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion chapters/lexicalstructure.tex
Expand Up @@ -260,7 +260,6 @@ \subsection{Units of Literal Constants}\label{units-literal-constants}

\begin{nonnormative}
Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing to perform dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_
Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the right-hand side unit.

On the other hand, literal constants showing up in expressions containing only literal constants should be left with the default \lstinline!unit = ""! attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, equations such as \lstinline!L = 2.0! and function calls such as \lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! would be erroneously flagged as dimensionally inconsistent.

Expand Down

0 comments on commit 942776f

Please sign in to comment.