The OK Function

Monday, May 4, 2009

I encountered a most awesome function today; it’s called OK.

OK accepts no arguments and returns either true or false. When a program needs to make a decision, it could ask if it’s OK or not. Interesting? You bet. But this is only half of the story. How does OK work?

When OK is called, it saves a snapshot of the current program execution state and returns true; it also installs a hook so that it is called at the end of the program. If the program ends successfully, OK does nothing. If the program fails, on the other hand, OK recalls the saved state and returns false.

Hmm…

3 Comments

  1. antimatter15 says:

    You’re the fourth result on a google search for “ok function”

  2. antimatter15 says:

    and what languages implement OK?

  3. Jiang Yio says:

    Hm… there are better languages for this, but: http://www.110mb.com/forum/-t45974.0.html

Leave a Reply