September 2013
Intermediate to advanced
548 pages
12h 25m
English
When we compile a program, the compiler provides us with helpful error messages if our source code is syntactically incorrect. Most of these are self-evident: if we omit a bracket, a comma, or a keyword, the compiler will give an error message with the filename and line number of the offending statement. The following are some errors we could see.
We’ll get the following error if the clauses that make up a function definition do not have the same name and arity:
| bad.erl | |
| Line 1 | foo(1,2) -> |
| 2 | a; |
| 3 | foo(2,3,a) -> |
| 4 | b. |
| | 1> c(bad). |
| | ./bad.erl:3: head mismatch |
Here’s some code containing unbound variables:
| bad.erl | |
| Line 1 | foo(A, B) -> |
| 2 | bar(A, dothis(X), B), |
| 3 | baz(Y, X). |
| | 1> c(bad). |
| | ./bad.erl:2: ... |
Read now
Unlock full access