Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
print_dialect.hpp File Reference

The dialect a function tree is printed in – who the text is for. More...

#include <ios>
Include dependency graph for print_dialect.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  bertini
namespace  bertini::node

Enumerations

enum class  bertini::node::PrintDialect { bertini::node::Classic = 0 , bertini::node::PythonReadable = 1 , bertini::node::PythonExact = 2 }
 Who a printed expression is for; selects the operator and constant spellings. More...

Functions

int bertini::node::PrintDialectSlot ()
 The stream-state slot the dialect is kept in (allocated once per process).
PrintDialect bertini::node::DialectOf (std::ios_base &stream)
 The dialect a stream prints in; Classic unless SetDialect was called on it.
void bertini::node::SetDialect (std::ios_base &stream, PrintDialect dialect)
 Choose the dialect everything subsequently printed to stream is written in.
char const * bertini::node::PowerSymbol (PrintDialect dialect)
 The power operator in a dialect: ^ for Bertini 1, ** for Python.

Detailed Description

The dialect a function tree is printed in – who the text is for.

Printing is a family, one member per audience (ADR-0059):

  • Classic: Bertini 1 input. Powers are ^; a complex constant is (re+im*I); every constant carries all of its digits. This is what System::to_classic_input and the CLI write, and what the classic parser reads back.
  • PythonReadable: what str(node) shows in Python. Powers are **; constants keep the same shapes as Classic (a bare real, (re+im*I)); readable first, exact where that costs nothing.
  • PythonExact: what repr(node) shows. eval of it in the bertini namespace rebuilds an equal node at full precision: a multiprecision real is real_mp('digits', precision), a multiprecision complex constant is Complex('re', 'im', precision), a non-integer rational is Rational('p/q'). Integers, and values a Python literal represents exactly, stay bare.

The dialect rides on the output stream (an std::ios_base slot), so the recursive node printers need no extra parameter and operator<< keeps working; a stream that nobody has set a dialect on prints Classic, which is what every pre-existing caller expected. Canonicalization (the content digest) uses none of these: identity is decided on the canonical encoding, never on printed text.