Post Aylna5DI3WsAmUSOTQ by wolf480pl@mstdn.io
 (DIR) More posts by wolf480pl@mstdn.io
 (DIR) Post #Aylna0qoHAVvFbuNsW by nytpu@tilde.zone
       2025-10-01T15:31:06Z
       
       0 likes, 0 repeats
       
       This C++ programming class is teaching about const *const, *const, const *, and such that even professional C programmers seem to fail to understand (I don't think I've ever once seen a constant pointer—rather than pointer to a constant—in any code other than mine) so that's a big thumbs up from at me at least
       
 (DIR) Post #Aylna2DXCAHlUNY2wC by loganer@mastodon.social
       2025-10-01T15:40:06Z
       
       0 likes, 0 repeats
       
       @nytpu ........wait, what?look, I have a hard time understanding what const by itself does let alone prefixed vs postfixed.
       
 (DIR) Post #Aylna35lwVfeCavMTg by loganer@mastodon.social
       2025-10-01T15:42:04Z
       
       0 likes, 0 repeats
       
       @nytpu the only time I really use const consistently is reference.`(const whatever_t& whatever)`
       
 (DIR) Post #Aylna45oDrIJIzwuAq by nytpu@tilde.zone
       2025-10-01T15:50:27Z
       
       0 likes, 0 repeats
       
       @loganer const * is a pointer to a constant, so you can't change the pointee's value but you can change what the pointer is pointing to* const is a constant pointer to a variable, so you can change the pointee's value but you can't change what the pointer is pointing toconst *const is a constant pointer to a constant, so everything's all constant, so what one would expect from just a single const in really any other programming language (other than Javascript which has even worse design decisions)References are a different matter and more sensible since they don't really have a distinction from “the reference itself” and “the thing being referenced”
       
 (DIR) Post #Aylna5DI3WsAmUSOTQ by wolf480pl@mstdn.io
       2025-10-01T15:55:44Z
       
       0 likes, 0 repeats
       
       @nytpu@loganer except in Java, where `final` is just a const reference to a potentially mutable object
       
 (DIR) Post #AymGGFbcbYZztLjWNc by nytpu@tilde.zone
       2025-10-01T21:17:09Z
       
       0 likes, 0 repeats
       
       @wolf480pl Yeah, that's the thing with Javascript's const too so they both have what IMO is a glaring issue (and makes const so pointless that they might as well not have added it)@loganer
       
 (DIR) Post #AymGbdXYoPDWCk2092 by wolf480pl@mstdn.io
       2025-10-01T21:21:01Z
       
       0 likes, 0 repeats
       
       @nytpu @loganerI think in Java, it's a little bit useful for reasoning about local vars. It's more useful for fields, since final fields is how you make objects immutable.It also makes some optimizations easier for the compiler, but smart compilers can infer that anyway...
       
 (DIR) Post #AymGj1AhLl45WSrD60 by nytpu@tilde.zone
       2025-10-01T21:22:21Z
       
       0 likes, 0 repeats
       
       @wolf480pl Yeah, I guess in Java final was really only meant for fields where they are useful.  But in JS I still maintain that const is just ruined (not totally useless I suppose), since it exclusively acts as * const in C/C++, and there's no way to indicate an immutable object@loganer