OpenMath / py-openmath

An OpenMath 2.0 implementation in Python
MIT License
15 stars 4 forks source link

Generalize the handling of symbol resolution #10

Open nthiery opened 6 years ago

nthiery commented 6 years ago

Currently one can register a callback for converting to Python an OpenMath symbol, based on cd and name. A more general mechanism would be to support registering callbacks based on:

Taking the cdbase into account is required anyway by the OpenMath standard. The others are practical in situations where all symbols in a given context (cd, cdbase) are handled identically, typically by loading the eponymous global Python object / functions.

Practical use case: in the pickle-based serialization, Florian recommends using a plain OMS symbol to represent a global Python objects; something like:

   <OMS cdbase=python cd=sagemath name=sage.foo.bar.baz/>

In that case, having to register all symbols would be unpractical.

nthiery commented 6 years ago

cc: @florian-rabe