What counts as public API#
This page says which functions may join the package's public API, such as
to_spec and to_latex. It is not about the operators a model may use; those
are the limits.
A function may join the public API when both of these hold:
- Same file in, same answer out.
to_spec('model.yaml')returns the sameSpectoday, tomorrow, and on a machine with no data and no solver. A function whose answer depends on data, a solver, the network or the clock cannot join. - No rule lives only in the code. Every rule the function applies is written on a page of this reference, so somebody could rewrite the function in another language from the pages alone and get the same answer.
Where a new feature lands#
When the language gained piecewise-linear curves, it gained a piecewise: key
in the YAML. A key in the file
shows up in a git diff, the typesetter prints it as math, and an engine written
in another language can read it. So wherever a feature can be a key in the
file, it is one.
What every function keeps#
- No state. No registry, no plugin, and no setting that changes what a
model means.
symbols=on the typesetter is the shape a legitimate option takes: it changes howloadprints and nothing about whatloadis. - A value or an error, and nothing between.
to_speceither returns aSpecor raises an error that names the rewrite.advice()is separate: it talks about a file the language accepts, and changes nothing. - Safe to call again.
to_program(program)returnsprogramunchanged.
Three things a function never decides#
- What one solver or file format can take. That is the engine's question.
- How the numbers bind to the names. That is the engine's too.
- Which solver runs.
What this refuses#
| Asked for | Why |
|---|---|
| A Python API for building models | The model is the file you review and diff |
| A hook, a callback, a registry, a plugin | Cannot be diffed, printed or read from another language |
| A function that binds data or calls a solver | Needs more than the file |
| A setting that changes what a file means | Two callers would read one file two ways |
| A function whose answer a declaration could give | A declaration can be diffed, printed and read from another language |