Skip to content

Comments

AtomBuiltin and decentral Atom box handling#469

Merged
sn6uv merged 1 commit intomasterfrom
unknown repository
Aug 3, 2016
Merged

AtomBuiltin and decentral Atom box handling#469
sn6uv merged 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Aug 2, 2016

A cleaner version of the Atom implementation used in Image[], that makes it easy to add new Atoms, such as Image[], Graph[], etc. without having to change central code in MakeBoxes.

Two changes:

(1) new AtomBuiltin (from #378); needed as a mechanism to register a builtin-like symbol that is actually an Atom (declaring an Atom directly does not register a name that could be used for constructing it in an Expression, so there always has to be an accompanying Builtin).

(2) moved out logic from class MakeBoxes(Builtin) into a new Atom.atom_to_boxes method, so that new Atoms need not add their logic (and import their symbols) to MakeBoxes but must instead provide an implementation of atom_to_boxes.

In the current implementation, MakeBoxes returns None on unknown Atom types. This PR changes this to raising an NotImplementedError for Atoms not implementing atom_to_boxes. As implementations are provided for Symbol, Integer, Rational, Real, Complex, String, this might only happen if new Atoms are added that do not properly implement atom_to_boxes.

@sn6uv sn6uv merged commit 8c1bd40 into mathics:master Aug 3, 2016
@sn6uv
Copy link
Member

sn6uv commented Aug 3, 2016

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants