Hacker News new | ask | show | jobs
by emef 1826 days ago

  # on_update="nothing": does nothing when an update is tried 
  frozen_shared_state = freeze(shared_state, on_update="nothing")
  frozen_shared_state.count = 4  # Does nothing, as this update did not exist
yikes. Thoughts on when this feature would ever be useful? Just the thought of working in a codebase with this subtle inconsistency makes me cringe.
2 comments

I'm guessing this would be most useful when interfacing with naughty code that you can't rewrite. E.g. you need to call a function from another library that does something useful and also modifies its argument, and you only want it to do the useful thing.
Yes, you're right with your concerns.

I added this feature yesterday. Note the default value is "exception". With "nothin" I was thinking in passing some frozen object through a pipeline of unsafe/inherited/bad code, but without polluting the console with warnings or stopping the execution with exceptions.