Macaulay2 » Documentation
Packages » MRDI » Namespace
next | previous | forward | backward | up | index | toc

Namespace -- option specifying the namespace for MRDI serialization

Description

A symbol used as an option to addSaveMethod, addLoadMethod, and saveMRDI to specify which namespace to use.

Different namespaces allow the same MRDI file format to represent objects from different computer algebra systems. The "Macaulay2" and "Oscar" namespaces are built in. Custom namespaces can be registered with addNamespace.

When passed to saveMRDI, this determines which set of save methods is used and what appears in the _ns field of the JSON output.

When passed to addSaveMethod or addLoadMethod, this determines which namespace the method is registered under.

The same object can be serialized under different namespaces.

i1 : saveMRDI 5

o1 = {"_ns": {"Macaulay2": ["https://macaulay2.com", "1.26.05"]}, "_type":
     "ZZ", "data": "5"}
i2 : saveMRDI(5, Namespace => "Oscar")

o2 = {"_ns": {"Oscar": ["https://github.com/oscar-system/Oscar.jl",
     "1.6.0"]}, "_type": {"params": {"_type": "ZZRing"}, "name":
     "ZZRingElem"}, "data": "5"}

Menu

Functions with optional argument named Namespace:

  • addLoadMethod(...,Namespace=>...) -- see addLoadMethod -- register a method for deserializing a type from MRDI format
  • addSaveMethod(...,Namespace=>...) -- see addSaveMethod -- register a method for serializing a type to MRDI format
  • saveMRDI(...,Namespace=>...) -- see saveMRDI -- serialize a Macaulay2 object to MRDI JSON format

For the programmer

The object Namespace is a symbol.


The source of this document is in /build/reproducible-path/macaulay2-1.26.05+ds/M2/Macaulay2/packages/MRDI.m2:892:0.