RunWithScissors() (2009)
android.googlesource.com
android.googlesource.com
https://legacy.reactjs.org/docs/dom-elements.html#dangerousl...
> This "function" has a superficial similarity to ‘unsafePerformIO’ but it is in fact a malevolent agent of chaos. It unpicks the seams of reality (and the IO monad) so that the normal rules no longer apply. It lulls you into thinking it is reasonable, but when you are not looking it stabs you in the back and aliases all of your mutable buffers. The carcass of many a seasoned Haskell programmer lie strewn at its feet.
> Witness the trail of destruction:
https://github.com/haskell/bytestring/commit/71c4b438c675aa360c79d79acc9a491e7bbc26e7
https://github.com/haskell/bytestring/commit/210c656390ae617d9ee3b8bcff5c88dd17cef8da
https://ghc.haskell.org/trac/ghc/ticket/3486
https://ghc.haskell.org/trac/ghc/ticket/3487
https://ghc.haskell.org/trac/ghc/ticket/7270
https://gitlab.haskell.org/ghc/ghc/-/issues/22204
> Do not talk about "safe"! You do not know what is safe!> Yield not to its blasphemous call! Flee traveller! Flee or you will be corrupted and devoured!
> Just like unsafePerformIO, but we inline it. Big performance gains as it exposes lots of things to further inlining. Very unsafe. In particular, you should do no memory allocation inside an inlinePerformIO block. On Hugs this is just unsafePerformIO
https://hackage.haskell.org/package/bytestring-0.9/docs/Data...
At some point, this function was moved to the newly created "Deprecated and unmentionable" group of functions with the comment
> Deprecated: If you think you know what you are doing, use unsafePerformIO. If you are sure you know what you are doing, use unsafeDupablePerformIO. If you enjoy sharing an address space with a malevolent agent of chaos, try accursedUnutterablePerformIO.
At this point, the two depreciated and unmentionable functions were actually just aliases of each other, with InlinePerformIO being depreciated, and accursedUnutterablePerformIO being merely unmentionable.
https://hackage.haskell.org/package/bytestring-0.10.10.1/doc...
It wasn't until version 0.11.0.0 that the friendly sounding name was finally removed.
Also shouts out to the UNSAFE_component methods, you’re a real hipster if you used those before the prefix
This method (actually not even a method but an attribute that probably calls a method if set) "bypasses" React to set the inner HTML of the element, hence "dangerous".
(But I get what you mean of course, the reply was not to you but anyone who isn't familiar with React)
Yes, it's funny but that's not the point. The important thing is that the name clearly conveys the message that you really shouldn't be calling it, as explained in the comments above the function definition.
The "funny but there's a real reason behind" aspect is a bit like https://xkcd.com/radiation/ : "It's for general education only. If you're basing radiation safety procedures on an internet PNG image and things go wrong, you have no one to blame but yourself." The sentence is funny but has a real purpose: protect readers and author.
> If we ever do make it part of the API, we might want to rename it to something less funny like runUnsafe().
I wonder, when you write that, why you wouldn't chose to rename it right away rather than using a funny name? Is it a strategy to avoid people using it? (runUnsafeAvoidUsing) or a strategy to make sure it doesn't get into the API? (wouldn't a flag or runUnsafeDontMakeItIntoTheApibe better )?
Some things in concurrent programming can result in deadlocks. That doesn’t mean that you round off all the corners and take away all the dangerous tools until you’re left with a kiddie playground as a programming environment. No, instead it means that the more experienced programmers on your team keep a sharp eye on how concurrency / multithreading is used in your program.
Not making excuses for the API—but this does seem like a difficult design space to work in.
I would not have approved this code.