# `Feel.Analysis.Images.Context`
[🔗](https://github.com/FeeJai/BDM/blob/feel-v0.1.0/apps/feel/lib/feel/analysis/images/context.ex#L1)

The rules for the context functions (`Feel.Analysis.Images`, D-170; `Feel.Builtin.Context`): `context`, `context merge`,
`context put`, `get entries` and `get value`.

The signatures say `Any | Null` for most of them, and a context is a context: the rules say what the entries of the one
that is given make of the result, and when it is `null`.

| Call | The type of the result |
| ---- | ---------------------- |
| `get value(m, key)` | the type of the entry `key` of `m`, for each key the type of `key` has; `null` for a key a closed context does not list; `Any` or `null` for one that an open context does not |
| `get entries(m)` | the list of the entries of a closed context, a context `{key, value}` for each (the list that has an element if it lists one); a list for an open one |
| `context put(m, key, value)` | the context `m` with the entry `key` set to the type of `value`, for each key (closed stays closed); any context for a key that is not known |
| `context put(m, keys, value)` | a context, and `null` where the path is not there |
| `context merge(ms)` | a context, and `null` unless every item of the list is one; a context alone is itself |
| `context(entries)` | a context, and `null` unless every item has a string `key` and a `value`, and the keys differ |

A context is a type with entries (`{:context, entries}` is **open**, it has at least these, `{:closed_context, entries}` is
**closed**, it has these and no others, D-65), and the entries of a type are present: an entry that may be absent is not a
thing a type says. So the result of `get value` for a key that the closed type lists is the type of the entry, and for one
that it does not list is `null`, and not an error (`Feel.Builtin.Context`).

Structural readers inspect excluded positive bases too. For `context(entries)`, an open context
may supply `key` and `value` even when its type does not list them; only a closed context proves
such entries absent.

A list of one context is that context (section 10.3.2.9.4), and so a list type is a context or `null`, as the list has one
item or not: a type does not say how many. The argument that takes a list (`context merge`, `context`) takes a context as the
list of it.

What the rules do not say: the order of the entries (a type is a map), which entries a merge of several contexts has (they
may all be there or not, and a type has no entry that is not there for sure), and the path of `context put` with a list of
keys, which a list type does not give in order.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
