>if your code has more than 3 levels of nesting you're doing something wrong
is he right?
If your code has more than 3 levels of nesting you're doing something wrong
Other urls found in this thread:
stackoverflow.com
github.com
twitter.com
Perhaps
Yes.
Perhaps
Yes.
Perhaps yes.
Yes
Was he including namespaces and scopes? Or is he only talking about loops?
>t. autistic faggot maintaining an autistic kernel written in an autistic programming language running on the sheer force of community autism
>namespaces
I've run into way too many name collisions in my time. Do you know how annoying it is to rename something essential and basic for your library because "PlaySound" is used by Microsoft without a namespace?
>Was he including namespaces and scopes?
No. He's using C, so we're only talking loops and conditionals (and are probably ignoring the outer level of functions). He might also not be including some ifs.
You can always chop your code up to make it obey these sorts of rules. It doesn't always make it better. Arbitrary rules can be gamed, but shit still sucks.
>Microsoft
Keep accumulating bad choices.
Yes, but that's still not an excuse for the abomination that is 8-space tabs.
I mean if you're doing 3+ loops over some data structure, you're running into really poor algorithmic performance, so that's not a totally stupid thing to say
>tfw updating JS from callback hell to async/await
3 levels? How about 33. Get rekt faget.
Not by choice
>Do you know how annoying it is to rename something essential and basic for your library because "PlaySound" is used by Microsoft without a namespace?
Sounds like "search and replace" one click job to me.
Sure, but the actual naming of things is hard, and I like to have elegant names for whatever I'm making. I care about code being self-documenting and not a complete bitch for my team to look through
well what are you gonna rename it to? PropagateAuralStimulus?
More like PropogateAnalStimulus, am I right?
For loops sure, but what about anonymous functions? Those can "nest" pretty easily.
STEM is mostly autism
C does not have anonymous functions.
If you're not using C, you're doing it wrong.
Really? That's your problem?
Meh, C++ is useful
C++ is absolute garbage, though.
Get some taste.
Yeah, you superiority-complex-having jerk. It is.
Namespaces (in the C++ sense) are absolutely fucking useless, and add nothing over just prefixing your variables with some shit, with the added cost of fucking up your ABI.
//yourlib.hpp
namespace yourlib {
void sepples_is_shit();
}
//mylib.hpp
namespace yourlib {
void sepples_is_shit();
}
That sure solved it.
>prefixing your variables
prefixing your names*
>bitches about Microsoft calling a shotgun on function name
>calls other people superiority-complex-having jerk
geeee
Not him, but what you are doing there is merely DECLARING the same function twice in the same namespace. As long as there is only one definition, there is absolutely no ambiguity whatsoever.
The real benefit of namespaces is not having to use the prefix in function definitions when using functions declared in the same namespace. You only have to add the namespace prefix only when calling them outside the namespace, unless of course using the "using" clause.
In C, you have to write the full name, prefix included, every time.
Prolly, depends on what I'm doing. If I'm in nesting hell I usually call functions instead
Linus Torvalds is always* right
When you think he is wrong it's because you don't know enough but once you learn enough you realise he was right again
Always bet on Linus
*maybe sometimes even Linus can be wrong
I still haven't found an instance where he's wrong
>prefixing your names*
prefixing your variable names*
in C yes
Can someone tell me a way to iterate over every cell in an n-dimensional array using less than n loops?
No idea, but ( stackoverflow.com
Map
C doesn't have n-dimensional arrays.
Even if you want that, the point is not that you shouldn't, is that you should put the loop body in an inline function.
so we don't
need to read
your code
like this
I hope this isn't that stupid >web developers meme
i don't even know what nesting is
go lift some weights, faggots
Howdo you make a 3D matrix without 3 levels of nesting?
if you're working with n>3-dimensional arrays you should probably start reconsidering your code lad
My video game has 4 spacial dimensions. What now?
in programming linux kernel? you dont need to
incase some nigger doesnt have a clue whats the point here
github.com
Linux kernel coding style
Linux kernel coding style
Linux kernel coding style
Linux kernel coding style
> >3 = 3
static void z_BufferTest_f(void) {
char buf[128] = { 0 },
org[128] = { 0 };
trap->Cmd_Argv(1, buf, sizeof(buf));
int i = '0';
char *src = buf;
char *temp = org;
//test
while( *src )
{
if (*src == NULL)
break;
*temp = *src; // t[0] = s[0];
*(temp + 1) = '^';
*(temp + 2) = i;
if (*src == '\0') {
*(temp + 3) = '\0';
break;
}
if ( i > '7')
i = '0';
temp += 3;
*src++;
i++;
}
trap->SendConsoleCommand(va("say %s\n", org));
}
This is just a humoristical old anecdote of his, damn Jow Forums why do you have to take everything so literally
What if I want to do tensor calculus?
if its a basic script then yes, if not then hes retarded.
while(1){//1
for(i = 0; i > player_count; i++){//2
if( Is player on foot[i]){//3
That is 3 levels in itself, this shit would obviously be nested inside of something else that was nested inside of a whole fucking game. easily 10 levels of nested bullshit
There was that one time when Linus thought he was wrong but it turned out his initial assessment was right all along.
The context is purely about kernel development. You wouldn't do something like that in the linux kernel.
Unless you're writing some iterative method that requires it, yeah that's pretty asinine.
How would you do this efficiently without using 5 nested loops? IIRC, this is a purely brute force solution, and thus function call overhead is significant.
Then the quote needs to be put back in context.
>function call overhead
Have you heard of inline functions?
>t. too stupid to use it
or MakeSound CreateSound or something like PlayMp3 PlayAudio