3 ms·
I think parent was alluding to mutability.
by gpderetta 5mo ago
I think parent was alluding to mutability.
- pjc50 5mo agoWhile I'm a big fan of immutable design, it makes some algorithms much more expensive and ultimately DRAM is mutable. And the example we're talking about could be a loop counter!
- antonvs 5mo agoA tail-recursive loop handles loops just fine, and is just as efficient. This is a perfect example of the misconceptions that mutable-first programming languages have caused. > ultimately DRAM is mutable Ultimately the CPU executes machine code, but I don’t see you directly writing that. You’re cherry-picking to defend an indefensible position.
- kccqzy 5mo agoYes! In lazy but immutable languages like Haskell, it is totally fine to refer to the value itself during definition. This is really the same idea that a recursive function can refer to itself during definition. It’s common to define a variable for the infinite list of prime numbers, where the definition requires the list of prime numbers itself. primes = 2 : sieve primes [3..] sieve (p:ps) xs = let (h, t) = span (< p*p) xs in h ++ sieve ps (filter (\n -> rem n p > 0) t) Here `primes` is a variable that refers to itself in its definition (called corecursion), and `sieve` is a recursive function.