refactor: make definition optional with EmptyDefinition sentinel#302
Merged
refactor: make definition optional with EmptyDefinition sentinel#302
Conversation
Split the monolithic src/Display/print.jl (~505 lines) into files by responsibility: - ansi.jl: ANSI color helpers and __print(::Expr) - definition.jl: __print_abstract_definition - mathematical.jl: __print_mathematical_definition - model.jl: Base.show / show_default for Model - pre_model.jl: Base.show / show_default for PreModel Pure refactor: no functional change. Display.jl updated to include the five files in dependency order. Related to AbstractDefinition refactor.
…cp_solution_types.jl
…rs to Building/model.jl
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make the
definitionfield optional inModelandPreModelby introducing atype hierarchy with
AbstractDefinitionas the abstract type, and concretetypes
Definition(wrapping anExpr) andEmptyDefinition(sentinel for nodefinition).
Key changes:
PreModel.definitiondefaults toEmptyDefinition()instead ofnothingModelis parametric onDefinitionType<<:AbstractDefinition__is_definition_set(::Model)always returnstrue(Model is structurally complete)__is_definition_set(::PreModel)returns!__is_definition_empty(pre.definition)definition!setter auto-wrapsExprintoDefinitionexpressiongetter: returns:(begin end)forEmptyDefinition,d.exprforDefinitiondefinitioninbuild()Base.showonAbstractDefinitionwith internal_print_abstract_definitionDisplay/print.jlinto 5 focused files by responsibilityAll 3609 tests pass.