Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the number of global objects #1379

Open
fingolfin opened this issue Jun 9, 2022 · 18 comments
Open

Limit the number of global objects #1379

fingolfin opened this issue Jun 9, 2022 · 18 comments
Labels

Comments

@fingolfin
Copy link
Member

After discussion with @fieker, we agreed that Oscar should try to minimize the number of global (non-function) objects it defines.

We should write up some rules for that and document this in the style guide. Two possible rules of thumb:

  1. global objects should be really, really important, and very frequently used in multiple applications
  2. global objects should be "as unique as possible"

Of course these are (necessarily) soft rules, but they give a rough idea, and if in doubt, we'll have to discuss it -- but if those are in the style guides, then at least people have a chance to act about them.

I'll try to illustrate further with concrete (counter) examples:

The current globals QQ and ZZ satisfy both of these: they are used virtually everywhere; and they are singletons, so it doesn't get more unique than that.

In contrast, we think that e.g. QQi, ZZi, QQBar should not be there (at least should not be exported to the user name space by default:

  • they are not used that much
  • they are not very "unique" (e.g. QQi is not even a NumberField, and differs completely from quadratic_field(-1)[1]; and QQBar is just "a" algebraic closer of the rationals, for very specific applications)

Thoughts, comments, ideas?

@thofma
Copy link
Collaborator

thofma commented Jun 9, 2022

I don't see the harm in QQBar and I can't think of other examples than ZZ and QQ fitting these criteria. So should the limit just be 2? Or we remove ZZ and QQ altogether to have a consistent system.

@tthsqe12
Copy link
Contributor

tthsqe12 commented Jun 9, 2022

Um, the list of global objects is quite a bit longer than this...
Just look at everything that has "ID" in its name in AA/src/generic/GenericTypes.jl

@fieker
Copy link
Contributor

fieker commented Jun 9, 2022

I'd limit it to at most QQ and ZZ. I don't see QQBar universally used, so I'd rather not have QQBar globally predefined. - neither QQi, ZZi, Qab, .... I think they are all niche types - most users will never use them.
The PolyID stuff are, as far as I can see the Dicts for cache=true - they are not exported (or should not be).
Maybe, to help move forward we need to have an .Oscar_init file where one can predifine more global objects?

@fingolfin
Copy link
Member Author

Regarding caches and FooBarID: as long as those are not exported, I don't have a problem with them (though perhaps we should use a convention like having the names of such "internal" variables be prefixed with an underscore).

I don't think and "oscar init file" is a workable solution, or at least it's not so easy to see how this should be done: for one thing, we'd only want this to be in effect when using Oscar is done from Main (so that package which use Oscar are not affected by this). And I am concerned how this would interact with precompilation?

@thofma
Copy link
Collaborator

thofma commented Jun 9, 2022

I don't understand the Oscar init file. If it is per user, it should go into $JULIAHOME/startup.jl. Otherwise it is just somewhere in Oscar.

@fieker
Copy link
Contributor

fieker commented Jun 9, 2022 via email

@thofma
Copy link
Collaborator

thofma commented Jun 9, 2022

I see. But I have some reservations about Oscar loading random files. I am also not sure what loading means. Load into which namespace?

To move forward we can

  1. just remove QQi, ZZi QQBar,
  2. write down in the developer documentation that we these are the only two exceptions.

@ulthiel
Copy link
Contributor

ulthiel commented Jun 9, 2022

As someone who may have initiated the discussion: I'm happy with ZZ and QQ only (but these should exist for convenience). I just thought that when it was decided there's QQBar, there could be QQAb as well. I was surprised by QQi and feared QQsqrt2 may come next.

@fieker
Copy link
Contributor

fieker commented Oct 11, 2022 via email

@lgoettgens
Copy link
Member

lgoettgens commented Jun 2, 2023

To move forward we can

  1. just remove QQi, ZZi QQBar,
  2. write down in the developer documentation that we these are the only two exceptions.

QQBar will be no longer exported, once #2445 is merged. QQi and ZZi seem to no longer exist.

@lgoettgens
Copy link
Member

Um, the list of global objects is quite a bit longer than this...

Yes, indeed. As of the current master (eb8ea10), the list is as follows:

julia> filter(name -> !(typeof(getfield(Oscar, name)) <: Union{Function, DataType, UnionAll}), names(Oscar)) |> (x -> show(IOContext(stdout, :limit => false), "text/plain", x))
29-element Vector{Symbol}:
 :ANTIC
 :AbstractAlgebra
 :CalciumQQBar
 :FieldElement
 :FlintQQ
 :FlintQQi
 :FlintZZ
 :FlintZZi
 :GAP
 :Generic
 :Graphs
 :Hecke
 :IntExt
 :Native
 :Nemo
 :OSCAR
 :Oscar
 :Polymake
 :QQ
 :QQBar
 :RDF
 :RationalUnion
 :RingElement
 :Singular
 :VarName
 :ZZ
 :error_dim_negative
 :inf
 :oscar

I would group them as follows:

(Sub)-modules of Oscar packages:

ANTIC
AbstractAlgebra
GAP
Generic
Graphs
Hecke
Native
Nemo
OSCAR
Oscar
oscar
Polymake
Singular

I think the cornerstones should be exported, but what about stuff like Generic and Native?

Often used rings/fields

CalciumQQBar
FlintQQ
FlintQQi
FlintZZ
FlintZZi
QQ
QQBar
ZZ

Summarizing the previous discussion, only QQ and ZZ should be exported.

Type unions

FieldElement
IntExt
RationalUnion
RingElement
VarName

In my opinion either export all or none (and then the same for the ones missing here like IntegerUnion).

Misc

error_dim_negative
inf
RDF

I have no idea what they are used for, so no idea.

@fingolfin
Copy link
Member Author

I am taking care of oscar and OSCAR in PR #2726, and of error_dim_negative in Nemocas/AbstractAlgebra.jl#1410 and TODO.

IMHO we also should not (re-)export at least these:

  • RDF
  • IntExt
  • VarName
  • Native

@lgoettgens
Copy link
Member

Updated list as of 91d2938

julia> filter(name -> !(typeof(getfield(Oscar, name)) <: Union{Function, DataType, UnionAll}), names(Oscar)) |> (x -> show(IOContext(stdout, :limit => false), "text/plain", x))
27-element Vector{Symbol}:
 :ANTIC
 :AbstractAlgebra
 :BasisLieHighestWeight
 :FieldElement
 :FlintQQ
 :FlintQQi
 :FlintZZ
 :FlintZZi
 :GAP
 :Generic
 :Hecke
 :IntExt
 :MPolyDecRingOrQuo
 :NCRingElement
 :Native
 :Nemo
 :Oscar
 :Polymake
 :QQ
 :RDF
 :RationalUnion
 :RingElement
 :Singular
 :Strassen
 :VarName
 :ZZ
 :inf

@fingolfin
Copy link
Member Author

removing also all unions and modules, we get this:

julia> filter(name -> !(typeof(getfield(Oscar, name)) <: Union{Function, DataType, UnionAll, Union, Module}), names(Oscar)) |> (x -> show(IOContext(stdout, :limit => false), "text/plain", x))
8-element Vector{Symbol}:
 :FlintQQ
 :FlintQQi
 :FlintZZ
 :FlintZZi
 :QQ
 :RDF
 :ZZ
 :inf

@fieker
Copy link
Contributor

fieker commented Oct 31, 2024

I'd also remove Flint*

@fieker
Copy link
Contributor

fieker commented Nov 6, 2024

Lars @lgoettgens is looking at removing the stuff

@lgoettgens
Copy link
Member

lgoettgens commented Nov 6, 2024

Triage decided to remove all uses of the four Flint* globals in Hecke (thofma/Hecke.jl#1674) and Oscar (#4261), then wait for some time, and then remove them (Nemocas/Nemo.jl#1935).

@fingolfin
Copy link
Member Author

What about RDF? Can we get rid of RDF?

I think after that and removing the Flint* objects we can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants