Formerly u/CanadaPlus101 on Reddit.

  • 31 Posts
  • 4.39K Comments
Joined 2 years ago
cake
Cake day: June 12th, 2023

help-circle







  • I mean, central planning would be more like the dairy board, but both the prices they sell for and the prices the farmers pay to suppliers are fixed at weird values, so they never can afford quite enough containers for the amount of product they produce, and have no reason to add new cheeses until things build to a crisis point and politicians are involved.

    Nothing is centrally controlled outside of what a normal business controls AFAIK, so it’s more of a plain legally enforced monopoly, like monarchs used to grant by letters of patent.




  • No, because I’m sure it’s passed the tipping point towards autocracy. There’s endless different forms of both it and democracy, but it’s a constant that democracy begets democracy and autocracy begets autocracy, so that’s my “line in the sand”.

    In America’s case as of now, all the checks and balances that used to work are still there, but they’ve been questionable for many years and aren’t going to do anything going forwards, so they’re functionally more like Canada’s monarchy.

    If you’re looking for a perspective on what’s normal and what’s not, consider that when there’s a big social problem in Canada, it’s only a matter of time until a law trying to address it gets passed. That’s what a functioning democracy is like. Meanwhile, there’s been a known place in the US where no courts have jurisdiction to prosecute serious crimes for two decades now.


  • I mean, “criticism” is a little extreme even, because it’s a humour post, and I was just riffing back.

    Apparently GCC does indeed do tail-call optimization at -O2

    Hmm, I wonder why it’s considered O2 heavy. The concept of turning tail recursion into loops is simple.

    But in that case, I’m not sure why the solution to the denial of service vulnerability isn’t just “compile with -foptimize-sibling-calls.”

    Probably because some of the recursion involved is non-tail. Actually, it looks like GCC might still be able to cases of corecursion where the functions are “stack compatibale”, but presumably most functions aren’t, and who knows what little knots they tied the parsing functions in this XML library into.


  • The basic definition would be something like use of a function in that function’s own code. It’s pretty easy to find examples that aren’t tail-recursive specifically, like mergesort, and examples within those that would overflow a hardware stack, like in OP. And that’s without looking at (mildly) exotic examples like the Ackermann function.

    Basically, the “Please leave recursion to math and keep it out of (in particular C) software” in OP means don’t define functions using those functions. It’s pretty and it can work, but not reliably.


  • I was answering a specific question put directly to me. There’s no “point”, exactly.

    Who here is misunderstanding how computers implement recursion?

    Taking a wild stab at how you might be reading this exchange, my original reply was about the title of the post, which implies a CompSci professor would be unhappy about someone criticising the use of recursion in code.

    (in a language that doesn’t have tail-recursion optimization)

    Wait, it doesn’t? I had kind of assumed GCC (for example) would do that at anything greater than -O0.







  • They don’t prevent it, they just don’t implement it. A real (physical) CPU is a fixed electrical circuit and can’t just divide in two the way it would have to for the ideal mathematical version of recursion. If you want a simple way to visualise this, how would you implement recursion (as opposed to just loops) on a Turing machine with tapes?

    Different CPUs might have strategies to approximate certain kinds of recursion, but at some point my own knowledge ends, and there has been many different designs. Tail recursion in particular is usually just turned back into a loop at the compiler, and typical modern architectures implement a call stack at the hardware level, which allows you to do limited-depth recursion, but breaks like in OP if you try to go too deep.