News for hackers. Stuff that matters.
Re:Another go at the Next Big Language by fauigerzigerk on Monday September 03, 2012 @03:00AM (#4469404)
A less flexible and less elegant way to avoid stack unwind in other languages would be to have a parameter that tells the invoked function what to do if an error occurs:

  def parse_log_entry(text, err_fn):
    entry = parse(text)
    if entry is None:
      entry = err_fn(text)
    return entry
Instead of passing a function, err_fn could also be some kind of resolver that finds a function for a condition name, or there could be a global recovery function:

  def parse_log_entry(text):
    entry = parse(text)
    if entry is None:
      entry = recover('invalid_log_entry', text)
    return entry

There are no comments on this comment yet.