You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Its unsafety is an exaggeration. It cannot guarantee to return a (good?) position for any arbitrary attribute, but that does not make it unsafe.
It could even be said that unsafeGetAttrPos is safer than readFile because it doesn't even throw an exception, but I'd consider them to be in the same class of reliability.
See that people don't want to use it because it's "unsafe"
Expected behavior
unsafeGetAttrPos causes a crash. I mean, that's what people would expect, but we ought to just fix the name by introducing an alias for the function. What about tryGetAttrPos?
nix-env --version output
Additional context
This is probably "cultural heritage" from Haskell's unsafePerformIO: a function that isn't inherently unsafe, but allows things to be done that shouldn't be possible within the language semantics. It can cause issues through interactions with other parts of the language that rely on referential transparency for memory safety, so the unsafe qualifier is appropriate there. However, it is quite safe to use in predictable circumstances, which I believe leads people to use the same qualifier for functions that are actually safe.
The text was updated successfully, but these errors were encountered:
Describe the bug
Its unsafety is an exaggeration. It cannot guarantee to return a (good?) position for any arbitrary attribute, but that does not make it unsafe.
It could even be said that
unsafeGetAttrPos
is safer thanreadFile
because it doesn't even throw an exception, but I'd consider them to be in the same class of reliability.Steps To Reproduce
Expected behavior
unsafeGetAttrPos
causes a crash. I mean, that's what people would expect, but we ought to just fix the name by introducing an alias for the function. What abouttryGetAttrPos
?nix-env --version
outputAdditional context
This is probably "cultural heritage" from Haskell's
unsafePerformIO
: a function that isn't inherently unsafe, but allows things to be done that shouldn't be possible within the language semantics. It can cause issues through interactions with other parts of the language that rely on referential transparency for memory safety, so theunsafe
qualifier is appropriate there. However, it is quite safe to use in predictable circumstances, which I believe leads people to use the same qualifier for functions that are actually safe.The text was updated successfully, but these errors were encountered: