avidamoeba

joined 1 year ago
[–] [email protected] 3 points 6 months ago (3 children)

Yes three are differences but you're running a redundant array of independent disks in order not to care about those differences.

[–] [email protected] 49 points 6 months ago

Just when you thought this couldn't get any more stupid.

[–] [email protected] 3 points 6 months ago

Any word on extension data sync between Android and desktop?

[–] [email protected] 1 points 6 months ago (1 children)

Have you stopped to consider why you can't explain it better? Perhaps the reason is because you're wrong.

Yes I have. You've already assumed I'm not too bright more than once and worked from there. There's no point in investing more work on my end. If what I said worked, good. If not, that's fine too.

[–] [email protected] 3 points 6 months ago* (last edited 6 months ago) (3 children)

Clearly I'm not referring to an if/else by saying two blocks. Even in my original example I show the exact issue. You don't understand it. I can't explain it better.

[–] [email protected] 3 points 6 months ago* (last edited 6 months ago) (5 children)

Yes clearly someone has to read the blocks at least once to ensure they are correct.

In subsequent reads, when I'm interested in the second block out of two, say during a defect analysis, I don't have to read the first one to be sure I'm going to reach the second. I can straight head for the second one and any subsequent stuff I care about. Multiple returns force me to read both blocks. I don't know what else to tell you. To me this is obvious and I think it's probably even provable. I don't know about you but I have to read a lot of existing code and every bit helps. We have pretty strict code style guides for that reason.

[–] [email protected] 5 points 6 months ago (1 children)

goto cleanup is not the same as return. I didn't badmouth goto cleanup.

[–] [email protected] 4 points 6 months ago* (last edited 6 months ago)

Not sure why you had to do the inverted predicate check again in your first example. You already have the information encoded in the value of retval. It can be written like this:

int result = 0;
if (!p1) result = -ERROR1;
if (p2) result = -ERROR2;
if (!p3 && p4) result = -ERROR3;
if (result != 0) {
    result = 42;
}

return result;

With a return value you have to add 4 extra lines. This overhead remains constant as you add more checks and more business logic.

Yes all the other suggestions are better than early returns in business logic and would help with leaks. Would be nice if we had RAII outside of C++. I think Rust has it? Haven't done Rust yet.

[–] [email protected] 7 points 6 months ago

That was the joke. 😂 I bet Windows is worse.

[–] [email protected] 3 points 6 months ago (7 children)

I meant assigning a return value then returning it is the sam as rnultiple returns. Anyway.

[–] [email protected] 5 points 6 months ago* (last edited 6 months ago) (10 children)

I don't think it's worse, I think it's equivalent. Also I don't like the risk of resource leaks which is inherent to multi-returns beyond input validation. And that's true beyond C because memory isn't the only resource that can be leaked.

It's not about how readable the branches are, it's about having to read all of them to ensure you understand the control flow so that you don't leak. Length of functions is a red herring. You want me to read the contents of short blocks to ensure the control flow is correct. I don't want to read the contents of those blocks, other than the conditional and loop statements. Reading short blocks is better than reading long blocks. Reading just the control flow lines is better than reading short blocks.

view more: ‹ prev next ›