I have flagged this question (c) as a duplicate, but one of the answers differs sufficiently from the answers to the target duplicate, that I’m doubting my belief.
Does anyone have any opinion on it? Is it a correct target duplicate?
@Andreasdetestscensorship It's about comparing types, which in a statically typed language like C, would be done at compile time, and not dynamically with function/variable/type names in the form of strings, which is what comes to mind with reflection.
@user16217248 The question doesn’t specify if it’s at runtime or compile-time. There’s nothing about «comparing types» that binds it to being a compile-time construct. In other languages, such as Swift, Java, C#, Python, etc, the type/class information is in the object’s header (functions are objects). This is what enables runtime type comparisons/safety.
@Andreasdetestscensorship But in C they aren't. They are just function pointers, typically 8 bytes, referencing a point in memory, that is supposed to be a function. C is so low level that 'type' information is typically mostly lost during compilation. It only tells the compiler which instructions to invoke when operating on the data really. Therefore unless you are emulating classes and objects in C manually all type-checking necessarily happens at compile time.
The only way that «checking the type» makes sense in terms of languages like C and C++, is with constexpr or the preprocessor. The quesiton asker already exposed discontent with this in a comment to the answer suggesting macros.
@user16217248 Well, they’re not happy with using macros, and their example code showed an if statement, which is a runtime construct.
@Andreasdetestscensorship In practice, the if (g==h) would check if the pointers point to the same function, so they probably want some kind of if (typeof(g)==typeof(h)) which C does not have that I am aware of. You could certainly use 'runtime' constructs with compile-time data, for example if (sizeof(int)==4). sizeof() is evaluated at compile time, but nothing is stopping you from using it in an if. In this case, whether if is a compile-time or runtime construct is not observable behavior.
@user16217248 That’s only because it’s inlined/optimized away by the compiler. At its core, it’s still a runtime check. sizeof is a fully compile-time construct, though. And a typeof, which is what it seems like they’re after, is where reflection comes into the picture.
Well, unless a typeof that causes a compile-time error if the type is unavailable at runtime, is sufficient to them. (Or it could have similar behaviour as sizeof, which is error-prone, and misleading).
@Andreasdetestscensorship And in C, a typeof (and any comparison operators applied to it) would have to be a fully compile-time construct just like sizeof.
@user16217248 Which is not the impression that I have the question is seeking, but I’ll give it the benefit of the doubt, and retract my flag. I’ll post a cv-pls if the asker confirms that it’s a duplicate of my suggestion.
jesus, making so many errors today, baby woke up the house at 4am, need more coffee to stay sharp
Question: stackoverflow.com/questions/76170803/… has already been asked today, earlier, but I don't remember by who, this seems to be the same person, who can check that?
I concur with Stephen; it's not a debugging question. You could re-request with a different reason if you think it's unclear, though it might help to clarify (ideally via a comment) what's unclear about it.
(although I see what you mean about debugging..."spring security intercepts the requests before I my controller can add the headers in the HttpResponse" could be construed as debugging that problem)
@HovercraftFullOfEels This duplicate seems closed incorrectly; the target is explaining what static variables are but the question here is asking how to make variables that aren't static
Is there a duplicate target/canonical for "how to declare variables that aren't shared between class instances"?
@TylerH: What is needed to answer the question, in its most pure sense, is an understanding of what static means and how static variables behave with Java. No, the duplicate doesn't specifically state, no, you can't do this with static variables, but I don't think that it has to. I have added another dupe that does specifically state this, but again, I don't see how this question, regardless of the dupe used to close it, is useful to future visitors. It doesn't even explain the use case.
@HovercraftFullOfEels I don't object to the request; I don't think the question is clear enough to serve as a reference for anything. I can't be sure what it's asking.
@jps Not from today, but someone apparently tagged their question [contacts], [android-contacts], and then, feeling that was not sufficient, created a new [contacts-android] tag and added that too, for good measure.
Heh, 2nd page of the reviews: > All the 5 star reviews are written by AI, as it's a requirement to post one in order to get free access for a week. Access to GPT-3.5 Turbo btw, GPT-4 Isn't free.
Yeah, any of the 1/2 star reviews are saying that they're pushing 5-star reviews. One noted that they also push Twitter follows.
Hahaha. One review starts with, "Written using this ;)", to which the team responded, "This is pretty cool! Thank you so much for your support, it means a lot to us! 😊"
@HovercraftFullOfEels I agree it's not a particularly good question, and the dupe targets do explain why OP is experiencing the issue he is experiencing, but they don't mention how to solve it; at least for me and my low level of Java programming, knowing that static variables are shared/the same variables for any instance of the class doesn't tell me how to have different variables between static classes or how to achieve what I'm wanting (e.g. in this case, a static variable).
You'd have to intuit it... is it just a matter of not using the static keyword? Or is there some other specific thing you gotta use when declaring them? the answer by OneCricketeer under the closed question (use protected, non-static variables) does... so maybe it is just better to add that explicitly to one of the top answers on the canonicals. Somehow none of them mention it...
Well, miken just cast the last delete vote, so it's a bit moot, now, anyway
I made two mistakes regarding a question with one of the newest nonsense tags issue 1. I didn't remove the tag prior to voting to migrate the question and 2. I even agreed to migrate that LQ question to superuser.com (apologies to the SU folks and shame on me :( Now I guess the question with its tags will stick around for longer. Can this be fixed by a mod before we get a real issue with this tag?
@miken32 I noticed the expression without following up on it, it's a surprising cartoon... From wiki:"The show first aired on 31 May 2004. The seventh season began broadcasting on 5 March 2021. Peppa Pig has been broadcast in over 180 countries" :D LOL
@GeneralGrievance This one is actually about programming, I did some HDL in Vivado and unless you do it full-time it's an insanely difficult experience.