|
http://gamesfromwithin.com/the-const-nazi I don't care about const tbqh
|
# ? May 14, 2015 00:21 |
|
|
# ? Apr 26, 2024 16:40 |
|
first view
|
# ? May 14, 2015 00:23 |
|
not using const makes you a literal butt
|
# ? May 14, 2015 00:27 |
|
bash the fash
|
# ? May 14, 2015 00:29 |
|
I don't use const, but 99% of my code is Objective-C so that's OK. edit: I kind of think that if your functions/methods are so long that you need to declare local variables as const just to know if they've changed, then you need to either declare the local variable closer to where it's actually used, or refactor that function. Doc Block fucked around with this message at 00:59 on May 14, 2015 |
# ? May 14, 2015 00:57 |
|
I'm just a regular Nazi, OP.
|
# ? May 14, 2015 00:58 |
|
Doc Block posted:I don't use const, but 99% of my code is Objective-C so that's OK. same. i don't really understand the use but Swift has let and var. who uses let? maybe there's good reasons, i dunno. haven't really got into Swift yet
|
# ? May 14, 2015 01:29 |
|
const died to me the day I learned that it doesn't really help the compiler in any significant way it also makes code a little annoying to read imo
|
# ? May 14, 2015 02:37 |
|
Symbolic Butt posted:const died to me the day I learned that it doesn't really help the compiler in any significant way its about helping the programmers to not gently caress up not the compiler "what? classes arent helping the compiler to generate better code? gently caress you i'm putting everything in global functions" although i guess there are several degrees of fascism, i dont make locals const myself quote:it also makes code a little annoying to read imo use auto all day erryday to remove useless noise which const isn't and have the pleasure of getting random coworkers asking if you are the crazy person who dared using a ~scary new c++ feature~ in the codebase
|
# ? May 14, 2015 02:57 |
|
c++ is trash city
|
# ? May 14, 2015 03:00 |
|
C++ is awful, don't use it, problem solved.
|
# ? May 14, 2015 03:10 |
|
Doc Block posted:I don't use const, but 99% of my code is Objective-C so that's OK. If your variable's const then a const version of the method will be called, and on types such as GNU copy-on-write std::strings that will be faster. Also your post is a fallacy, using const increases the size you can make functions while they're still readable.
|
# ? May 14, 2015 03:11 |
|
wow nice fallacy fucktard
|
# ? May 14, 2015 03:26 |
|
i mean that if a function is so long that a quick look through doesn't tell you whether or not a local variable gets changed then you need to probably refactor that function, rather than slapping const in front of the variable's declaration and calling it a day. at least rewrite so all the code that does a certain thing is all in one area of the function, so the variables used will be declared close by and you can easily see if they get changed or not.
|
# ? May 14, 2015 03:30 |
|
Doc Block posted:i mean that if a function is so long that a quick look through doesn't tell you whether or not a local variable gets changed then you need to probably refactor that function, rather than slapping const in front of the variable's declaration and calling it a day. at least rewrite so all the code that does a certain thing is all in one area of the function, so the variables used will be declared close by and you can easily see if they get changed or not. member variables start with m_ function variables with f_ first letter after is type use descriptive camel case m_bDickIsInBox
|
# ? May 14, 2015 03:54 |
|
Doc Block posted:i mean that if a function is so long that a quick look through doesn't tell you whether or not a local variable gets changed then you need to probably refactor that function, rather than slapping const in front of the variable's declaration and calling it a day. at least rewrite so all the code that does a certain thing is all in one area of the function, so the variables used will be declared close by and you can easily see if they get changed or not. Somebody doesn't understand continuity arguments.
|
# ? May 14, 2015 03:58 |
|
No Flash? Try the QuickTime video version.
|
# ? May 14, 2015 04:16 |
|
I am indeed a const nazi, but most of my work is done in windows ce so my opinion is irrelevant in 2015.
|
# ? May 14, 2015 04:17 |
|
I guess I don't know what a continuity argument is, unless you mean a parameter that gets passed to a function/method just so it can pass it on to something else. But that doesn't have a whole lot to do with declaring local variables as const, so vv
|
# ? May 14, 2015 05:54 |
|
LP0 ON FIRE posted:same. i don't really understand the use use let unless you specifically need to use var
|
# ? May 14, 2015 06:57 |
|
rust did it right. you should have to do more typing to make something non-const
|
# ? May 14, 2015 06:58 |
|
Symbolic Butt posted:const died to me the day I learned that it doesn't really help the compiler in any significant way it can help the compiler though, example: code:
the compiler can assume MyFooDidBarNotification never changes and doesn't need to reload it every use
|
# ? May 14, 2015 07:00 |
|
all the old men use const it is there for a reason
|
# ? May 14, 2015 09:22 |
|
no nazi propaganda in the 'POS ban gas op thread
|
# ? May 14, 2015 10:30 |
|
As a Millennial I posted:No Flash? Try the QuickTime video version. even for 2010 that's shameful
|
# ? May 14, 2015 11:05 |
|
const entration camp
|
# ? May 14, 2015 12:23 |
|
const is Good and Correct and should be used everywhere. on variables, on functions. all in the aid of not violating assumptions. similarly, you should strive for idempotence in everything you do, and name the unavoidable exceptions things that make it obvious that they're exceptions
|
# ? May 14, 2015 13:11 |
|
i just use languages in which the const is implicit and you need to put a 'mut' (or a new[STRef|IORef|Mvar] et al)
|
# ? May 14, 2015 13:17 |
|
eschaton posted:it can help the compiler though, example: but isn't the issue that MyFooDidBarNotification can actually change because of pointer aliasing? the way I heard about it is that the compiler has to always figure out if the variable is really constant so the const declaration end up making no difference
|
# ? May 14, 2015 13:26 |
|
Zlodo posted:its about helping the programmers to not gently caress up not the compiler dude functions are like super great I loving love functions anyway I use enums for global constants instead of const or #define and that's pretty much my pseudo-const correctness practice
|
# ? May 14, 2015 13:33 |
|
Doc Block posted:C++ is awful, don't use it, problem solved. fiat dollars are awful use bitcoin instead
|
# ? May 14, 2015 16:05 |
|
yeah i go crazy with const, that way all my spaghetti templates and poo poo get compiled into 1 liners that could have been easily represented in plain C but i really want my compile times to increase by 50 orders of magnitude
|
# ? May 14, 2015 16:11 |
|
lmao, templates.
|
# ? May 14, 2015 16:14 |
|
i sometimes call c++ c-- because its actually worse than C!!
|
# ? May 14, 2015 16:18 |
|
Doc Block posted:C++ is awful, don't use it, problem solved.
|
# ? May 14, 2015 17:25 |
|
const is a contract in your function declaration. #define LOCAL_VALUE 0x42069
|
# ? May 14, 2015 17:27 |
|
Only place for const is at the top of the file:Objective-C code:
Objective-C code:
Doc Block fucked around with this message at 18:07 on May 14, 2015 |
# ? May 14, 2015 18:03 |
|
R# tells me to make something const, I make it const same with var
|
# ? May 15, 2015 10:39 |
|
ES6 has const
|
# ? May 15, 2015 12:01 |
|
|
# ? Apr 26, 2024 16:40 |
|
it also has let
|
# ? May 15, 2015 12:01 |