Skip to content

Commit

Permalink
Wrote out LHS and RHS
Browse files Browse the repository at this point in the history
  • Loading branch information
casella committed Oct 26, 2022
1 parent bdbea3b commit eb116d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chapters/lexicalstructure.tex
Expand Up @@ -257,8 +257,8 @@ \subsection{Units of Literal Constants}\label{units-literal-constants}
\begin{nonnormative}
Rationale: unit attributes allow to check dimensional consistency of expressions and equations, as long as all the involved terms have a non-empty \lstinline!unit! attribute.
Non-dimensional literal factors, e.g., \lstinline!2! in \lstinline!v = sqrt(2*g*h)! in physical laws involving quantities with units are always meant to be dimensionless, so they should be considered as such by giving them \lstinline!unit = "1"!.
This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the LHS and unit \lstinline!"m0.5"! on the RHS, which are not consistent.
Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the RHS unit.
This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the left-hand side and unit \lstinline!"m0.5"! on the right-hand side, which are not consistent.
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 eb116d7

Please sign in to comment.