-8

A relatively new question asker asked:

The question body contains additional detail about why they are trying to do this.

Going just by the text in the title, this question seems fine to me: it's clear what the asker is asking to do, and it has a definite answer (which happens to be that it is not possible). It also seems like a question that other people might have. Yet, I didn't find any duplicates after a cursory search.

However, this question has now been closed as "needs details or clarity". On its face this seems incorrect: the question contains many details about the intended use, the code base in question, etc. It is also clear from the title, and those details, what the asker is trying to accomplish.

Clicking through to the closed questions page that is linked from the "needs details" close message text, I do not see any additional provision that the question violates. In particular, under the "needs details" bullet it simply repeats the need for detail, but again, this question has plenty already, and I cannot think of any additional detail that would improve the question.

The only reason I can readily think of for why this question is poorly received is it is very basic. At Asking questions as a beginner/newbie, and similar questions, the consensus seems to be that beginner questions are allowed as long as they aren't duplicates and show some level of effort by the asker to solve the problem. This question appears to meet both criteria.

I'm aware I have enough rep on the site to vote to reopen. I'm also aware I could have upvoted the question earlier and that might (?) have worked to avoid the closure in the first place. (I have upvoted now.) My further inaction is because I'm wondering if I'm missing something.

Hence my question, finally: should this question be closed?

3
  • 5
    Upvote wouldn't have done diddly to stop closure. Voting can block deletion, but closing is untethered from the score except ideologically (a closed question, except those with historic significance, is a "bad" question). That doesn't mean that there are no disputes over what constitutes a bad question. Commented Aug 19, 2023 at 22:21
  • I've now edited the question to try to resolve the issues identified by Karl. Commented Aug 20, 2023 at 10:28
  • 2
    Why isn't it possible? If they are on the heap, couldn't the memory allocation routines be trapped/intercepted (and making some implementation-dependent assumptions)? There is even a facility for it in C++(?). It may not be according to the standards, but who says it must be? Assigning to a constant writes to a memory address on embedded systems (definitely not standard). Commented Aug 20, 2023 at 14:12

1 Answer 1

14

This question seems fine to me: it's clear what the asker is asking to do, and it has a definite answer (which happens to be that it is not possible)

Not only is the task not possible in the abstract, it makes absolutely no sense whatsoever, a priori, to expect it to be possible. It would be like expecting to be able to determine a person's home address according to the exact shade of the person's shirt, or locate a person based on simply knowing exactly who it is.

The question seems to hint at some extenuating circumstances that would make it at least technically possible (e.g., having access to some kind of global collection of instances to iterate over and check), but there isn't the necessary information present to be able to verify that. I.e., OP is talking about "looping through all the instances" - this is trivial if there is a known collection of "the instances", and effectively impossible otherwise. Alternately, because these instances are described as "ID" values, it could be intended that they can be used with some existing API to look them up; but figuring that out would require reading through a GitHub repo - not the sort of thing we do here.

Basically, OP is asking for help with someone else's code, without including the relevant portion of that code in the question (and seemingly not knowing what portion is relevant).

The rest of the question makes matters worse:

As this is a learner's question, I would welcome just a 'pointer' (pun intended) to an existing answer, the area of C++ that I need to study to do this, such as the name of the relevant language feature or the relevant lesson on LearnCPP.com (which I am working through).

We don't entertain this sort of thing. First off, OP has started to write as if this were a discussion forum, which it is not. We don't need to be told to close duplicate questions; that's automatic, and the suggestion is noise. Describing an "area of study" is out of scope here, and we don't point at resources and such.

I found this similar question, but it's for Objective-C, but not for C++. The answers recommends the factory and singleton patterns, but they seems to be for instantiating new objects, not accessing existing objects in a large codebase, and the singleton pattern seems to be controversial.

This is utterly irrelevant, and the other question also should be closed. It's talking about reusing an existing instance and strategies for keeping track (i.e., the Singleton pattern) of whether that instance was created by one's own code - not about how to regain track of an instance which was lost (or never known, only some information is known about it). The other question also has the problem of carrying multiple language tags while not showing any code and not being clear about whether it's intended to be language-agnostic or just what.

The only reason I can readily think of for why this question is poorly received is it is very basic.

No; it's poorly received because it doesn't make sense. It doesn't make sense to ask as asked, and it isn't clear whether OP is actually on a fool's errand or whether there's some important detail missing that would create that sense.

At Asking questions as a beginner/newbie, and similar questions, the consensus seems to be that beginner questions are allowed as long as they aren't duplicates and show some level of effort by the asker to solve the problem. This question appears to meet both criteria.

There is no restriction based on question difficulty. However, "beginner" questions still have to meet every other qualification.

Keep in mind that the goal here is to build a reference library. That means we want questions that could potentially become someone else's duplicate in the future. Many "beginner" questions do an excellent job of this - things like "how do I open and read from a file in X language?". Many others do not. A lot of the time that's because there's an issue with failure to think clearly about the underlying problem, even on a level that doesn't require any understanding of programming.

10
  • 6
    In database systems, looking up objects by their attributes is common. I don't think it's so ridiculous for someone to think that might also be possible in an unfamiliar programming language. Commented Aug 19, 2023 at 20:02
  • 8
    Looking up objects in a database by their attributes is not at all common when you don't actually have access to the database. And OP has already demonstrated an understanding of how to perform the task if there is an already known collection of candidate instances. Commented Aug 19, 2023 at 20:04
  • 6
    Why is it nonsensical to imagine that the language might maintain its own collection the programmer could access? Someone asked how to do that in Java and that question is +19. Someone asked the same about c#, which is at +1. Together they have 18k views. Commented Aug 19, 2023 at 20:50
  • 4
    Although I still don't agree that the core question contains a nonsensical premise, this answer has been very helpful for understanding why the question was received the way it was, so I'm accepting it. I've also now edited the question to try to fix the issues identified here. Commented Aug 20, 2023 at 10:31
  • Although I'm sure OP would protest, I think the edited version is better off without the context section at the end. It adds nothing to the actual understanding of the question. Instead, it could have a brief, inline description of a possible motivation for the task. It would also have to be specifically excluding the possibility of an external collection having been explicitly coded in or available through the API; it seems you've identified a "Q. is there an internal collection created automatically by the language? A. No" question. Commented Aug 20, 2023 at 10:34
  • 1
    If you can come to an agreement with OP about this, and edit your own answer to match, I would be happen to vote to reopen. Commented Aug 20, 2023 at 10:36
  • 2
    I doubt the OP will protest any edits at this point, as the question is at -5 and they're probably pretty discouraged. I think the background is potentially useful context since it addresses at least some of the "why don't you just do X?" objections. Plus the close reason was "needs details". I've shorted it further, and added clarification that the OP desires a standard solution if one is available (which I believe to be the case based on their comments). Commented Aug 20, 2023 at 11:07
  • @Scott McPeak: Yes, I welcome edits. I have already learned that C++ does not provide such a facility. But I would like the answer to help other learners who may face the same situation.
    – Matthew
    Commented Aug 21, 2023 at 15:56
  • "This is trivial if there is a known collection of "the instances", and effectively impossible otherwise". This is the key point, I think. Without a complete knowledge of C++ (which learners by definition do not have), how can a learner know whether there is a known collection of "the instances" or not? I can read 100 tutorial chapters only to find it's explained in chapter 101. I have now been told that C++ does not keep such an index, but you seem to assume that it is technically possible that it could do. And even if it's trivial, learners would still need to learn the language to do it..
    – Matthew
    Commented Aug 21, 2023 at 16:11
  • 2
    A comment on the OP pointed to a question about [getting all objects of a class in C++. The question states it is possible to do this in another language (may or may not be true, but shows it's plausible). This is similar to OP, because once you have references to all objects in class then you might know how to iterate through them. But it raises an XY problem: if you possess more information than assumed in that post, it might change the best answer. So not an exact duplicate.
    – Matthew
    Commented Aug 21, 2023 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .