# How Scheme misunderstands infix expressions

## (2 + 3)

```> (2 + 3)
(bug) procedure application: expected procedure, given: 2; arguments were: #<primitive:+> 3
```

When DrScheme sees the left parenthesis at the beginning of the expression ``(2 + 3)`', it expects the expression to be a procedure call, and it expects the procedure to be identified right after the left parenthesis. But ``2`' does not identify a procedure; it stands for a number. (A ``procedure application'' is the same thing as a procedure call.) Since it expected a procedure and was given a number instead, it gave up and printed out the error message instead of trying to carry out a command that it regarded as senseless.

The other expressions in a procedure call are supposed to identify its arguments, that is, the values to which the procedure should be applied. DrScheme looked at these expressions -- ``+`' and ``3`' -- and correctly noted that the former stands for the built-in procedure for addition (that's the ``<primitive:+>`' stuff in the error message) and the latter for the number 3. DrScheme didn't see anything wrong with those arguments. The only error it recognized was the error of putting an expression that doesn't identify a procedure right after the left parenthesis at the beginning of a procedure call.

## 7 * 9

```> 7 * 9
7
#<primitive:*>
9
```

In the absence of parentheses, DrScheme sees ``7 * 9`' as three separate and unrelated expressions -- the numeral ``7`; ``*`', a name for the built-in multiplication procedure; and ``9`', another numeral. It interprets each of these expressions as a separate command, requiring a separate evaluation: ``Compute the value of the numeral ``7`'! Find out what the name ``*`' stands for! Compute the value of the numeral ``9`'!'' So it performs the first of these commands and displays the result `7`; then it carries out the second command, reporting that ``*`' is the name of the procedure `*`; and finally it carries out the third command and displays the result, `9`. This behavior is confusing, but it's strictly logical if you look at it from the computer's point of view (remembering, of course, that the computer has absolutely no common sense).

## sqrt(49)

```> sqrt(49)
#<primitive:sqrt>
(bug) procedure application: expected procedure, given: 49 (no arguments)
```

As in the preceding case, DrScheme sees ``sqrt(49)'` as two separate commands: ``sqrt`' means ``Find out what the name ``sqrt`' stands for!'' and ``(49)`' means ``Call the procedure `49`, with no arguments!'' DrScheme responds to the first command by reporting that ``sqrt`' stands for the built-in procedure for computing square roots and to the second by pointing out that the number `49` is not a procedure.