you could i guess like attach the ast to the closure value and substitute in the values of the closed-over variables but that seems like overkill for something that would almost never come up
like seriously, make them impossible to compare is the only sane answer
Comparing them is very useful though, even if it just checks identity. Eg. adding or removing a event listener
Comparing by AST seems problematic since you could make a minor change to one "copy" of a function and break a lot of logic that might depend on them being equal, or not equal
maybe a less insane alternative would be, if a closure is represented as a function pointer and the closed-over values, just comparing all of those raw
especially since a use case like that would probably really not want it to be possible to have "the same" closure written two different places
I wonder why so few languages do it that way though, then I wouldn't need to useCallback every single function in react to make them compare equality properly
In the faq it says that we need to delete published answers
After some researches I found these two questions:
Should I delete my sandbox answers after posting the challenge?
We Have a Messy Sandbox
where the community votes to delete the answers in sandbox after publishing:
But in reality a...
Given a base as input, output all pan-digital numbers. A number is pan-digital if it includes every digit in that base at least one. Every number is considered to contain infinite number of leading 0s.
sequence rules apply. You may either: given a base and a index, print the n-th pan-digital numb...
@Seggan I can see the reason in languages where the exact memory something requires is important. But still you'd probably wrap it in some kind of wrapper like Box<dyn> so it doesn't matter normally
Since we've decided to officially recognize TNB's off-topic room Off-Topic TNB, it might be a good time to give it its own name.
We'll do this the same way we decided on TNB's name; post one room name per answer. If you think the current name is the best option, feel free to create an answer with...
> Rust has successfully embodied everything I want to avoid in a PL -- godawful syntax, bloated semantics, a fanatical community that makes poor rationalizations for it sucking as bad as it does, the ad hoc feel of the whole thing. If a language promising memory safety is infuriating (or, as they put it euphemistically, "has a steep learning curve") to the point that it makes you just want to do the memory management, yourself, you know it's a turd.
Its traits and structs and enums and stuff are a great alternative to traditional OOP, it keeps a lot of the cool stuff from JS (which makes it feel nice to use to me) while dropping the jank, its compiler is amazing at helping you figure out bugs, etc.