Skip to content

Avoid global state / global settings, esp. with common names #13

@fingolfin

Description

@fingolfin

From read.g:

MIP_GLLIMIT := infinity;
COVER_LIMIT := 100;
POWER_LIMIT := 1000;

# some flags for the algorithm
if not IsBound(USE_PARTI) then USE_PARTI := false; fi;
if not IsBound(USE_CHARS) then USE_CHARS := false; fi;
if not IsBound(USE_MSERS) then USE_MSERS := false; fi;

# checking modes for the package
if not IsBound(CHECK_AUT) then CHECK_AUT := false; fi;
if not IsBound(CHECK_STB) then CHECK_STB := false; fi;
if not IsBound(CHECK_CNF) then CHECK_CNF := false; fi;
if not IsBound(CHECK_NQA) then CHECK_NQA := false; fi;

# store info
if not IsBound(STORE) then STORE := true; fi;
if not IsBound(COVER) then COVER := true; fi;
if not IsBound(ALLOW) then ALLOW := true; fi;

These are problematic because it means the results of computations can vary based on some invisible global state. It is e.g. conceivable that a user sets a variable like STORE for unrelated reasons, not knowing that this will affect modisom.

Possible solutions (which may be mixed as desired):

  1. add a prefix identifying the package, such as MODISOM_, so that we have MODISOM_ALLOW
  2. use the GAP package namespace feature; so e.g. ALLOW@ etc. -> this is turned internally by GAP into ALLOW@Modisom
  3. some of them these settings could perhaps be turned into GAP options, so that the user can set them for specific function calls instead of globally

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions