Intentional Programming
Intentional programming is a name given to a style of
programming where we can easily see what was intended by the
programmer. The intention of the programmer should be obvious
from the names of the functions involved and not be inferred by
analyzing the structure of the code. This is best explained by
an example. In the early days of Erlang, the library module
dict exported a function lookup/2 that had
the following interface:
| | lookup(Key, Dict) -> {ok, Value} | not_found |
Given this definition, lookup could be used in three different
contexts.
-
For data retrieval, we could write the following:
{ok, Value} = lookup(Key, Dict)Here
lookupis used to extract an item with a known key from the dictionary. If the key ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access