Skip to content

Can we introduce a convention to ask whether or not a property of an object is known? #4394

Open
@HechtiDerLachs

Description

@HechtiDerLachs

This has been touched upon in triage today when discussing #2721: Many times one has properties of an object which are potentially expensive to compute; one example being the dimension of an ideal. For MPolyQuoIdeals this is not known a priori. Yet one eventually wants to make an informed decision based on whether this property is known.

A dirty way to do this is to look whether or not a (hopefully corresponding) attribute is set; like for instance

if has_attribute(I, :dim) && dim(I) == 0
  # do something which takes advantage of the information that we have a 0-dimensional ideal
else
  # do something else
end

This has the disadvantage that not every concrete type of ideals has the information stored as an attribute. Maybe some of them use fields in the struct? So what one really wants to have is an official way to ask whether this information is present; just like

if has_known_dim(I) && dim(I) == 0
  # do something which takes advantage of the information that we have a 0-dimensional ideal
else
  # do something else
end

I would propose exactly this syntax: has_known_XYZ where XYZ is the name of the usual getter for the respective property.

But I'm afraid that similar things already have emerged and spread over OSCAR in other areas and people have used other names. If you are aware of such instances: Could you point them out here, so that we can gather them?

Then we could eventually make progress towards some informed decision whether we really want this feature and if so, in which form.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions