News for hackers. Stuff that matters.
Re:CLion Nova Explodes onto the C and C++ Development Scene by vips7L on Thursday November 09, 2023 @11:38AM (#38207254)
We've taken this approach with var in Java. If we can't tell the type from the right hand side it should be declared on the left.

    var m = new Thing(); // you know its a thing

    var t = a.b().c(); // what is it?
Re:CLion Nova Explodes onto the C and C++ Development Scene by PaulDavisThe1st on Thursday November 09, 2023 @12:07PM (#38207674)
in loops, the lack of knowing can be considered a positive though:

   for (auto const & thing : container_of_things) {
         thing->method ();
   }
in this context (and this context alone) i love not knowing or having to explicit denote the type of "thing".
Re:CLion Nova Explodes onto the C and C++ Development Scene by fluoridation on Thursday November 09, 2023 @12:09PM (#38207694)
Naming issues aside, the type of t shouldn't matter, in the same way that the type of a.b() doesn't matter. What matters is how t relates to the code around it. What's the purpose of t in the context where it's used? What does it store? If you don't know whether t is an iterator over a sequence, the timestamp of an event, or the measurement of a sensor, knowing whether t is an int or a string won't help you much. If you do know that, knowing the specific type of t will probably not provide much more additional information, since in any given codebase for almost all non-primitive types there's at most two different types with comparable purpose.
Re:CLion Nova Explodes onto the C and C++ Development Scene by vips7L on Friday November 10, 2023 @09:55AM (#38219581)
Types are context.
Re:CLion Nova Explodes onto the C and C++ Development Scene by neuromanser on Thursday November 09, 2023 @12:16PM (#38207828)

    var t = a.b().c(); // what is it?
Most likely bad code (on the right hand side)

https://en.m.wikipedia.org/wiki/Law_of_Demeter

Re:CLion Nova Explodes onto the C and C++ Development Scene by vips7L on Friday November 10, 2023 @09:57AM (#38219615)
I agree but my coworkers don’t :)