News for hackers. Stuff that matters.
Re:Why Do Python Lists Multiply Oddly? Exploring the CPython... by arijun on Tuesday April 09, 2024 @03:43AM (#39977034)
Why are you comparing functions/closures with values? You can do the same in python:

  [list() for _ in range(4)]
Re:Why Do Python Lists Multiply Oddly? Exploring the CPython... by bmitc on Tuesday April 09, 2024 @03:58AM (#39977100)
> Why are you comparing functions/closures with values?

I'm not. The fun _ -> [] is needed because the argument is the element's index. That's just what List.init happens to expect, a function that takes an index and initializes the element, but the index is not needed here.

Re:Why Do Python Lists Multiply Oddly? Exploring the CPython... by arijun on Tuesday April 09, 2024 @04:16AM (#39977191)
Are you saying f# special-cases something that looks like a closure, but isn’t in this one context? Because that, to me, seems like a much more grievous issue than the one at hand.
Re:Why Do Python Lists Multiply Oddly? Exploring the CPython... by bmitc on Tuesday April 09, 2024 @04:23AM (#39977228)
No. F# lambdas are closures. I was just saying that I'm not using the concept of closures to explain here. It's just a side effect of using the List.init function as a demonstration.
Re:Why Do Python Lists Multiply Oddly? Exploring the CPython... by arijun on Tuesday April 09, 2024 @04:36AM (#39977339)
(I can’t respond to your other comment)

Ah I see, you’re saying that the construction of a list in F# mandates a lambda, thereby reducing one possible point of confusion. I could agree with that. But then it comes at a cost of comfort: [0]*4 has less boilerplate than the F# version. So it comes down to trade-offs again.