News for hackers. Stuff that matters.
Re:Frankenstein's `__init__` by eptcyka on Saturday April 19, 2025 @11:35AM (#43737120)
What if the object is in an invalid state unless the thread is started?
Re:Frankenstein's `__init__` by greatgib on Saturday April 19, 2025 @12:03PM (#43737293)
Nothing prevents you to have a valid "not_yet_started" state.
Re:Frankenstein's `__init__` by rcxdude on Saturday April 19, 2025 @12:10PM (#43737338)
No, but it does complicate things substantially. I don't understand why you would have a useless half-constructed state, especially in python where init isn't all that magical.
Re:Frankenstein's `__init__` by lgas on Saturday April 19, 2025 @02:59PM (#43738602)
The benefits of making illegal states unrepresentable are just not widely understood outside of pure FP circles. I think it's hard for stuff like this to catch on in python in particular because everything is so accessible and mutable, it would be hard to talk about anything that provides the level of confidence that eg. ADTs in Haskell provide. And it's hard to understand why you would want to try to do something like that in a context like python unless you already have experience with it in a statically typed context.
Re:Frankenstein's `__init__` by eptcyka on Saturday April 19, 2025 @01:31PM (#43737907)
And what would you do with this object after construction? Call start() on it immediately?
Re:Frankenstein's `__init__` by greatgib on Saturday April 19, 2025 @02:31PM (#43738374)
Kind of yes or no, depend on your usage. But clearly would have worked well for the case of the automatic test if the start was the context
Re:Frankenstein's `__init__` by int_19h on Tuesday April 22, 2025 @07:14PM (#43767166)
This is basically equivalent to what null is for pointers, and has all the same problems.