On Mar 18, 2006, at 5:05, Allison Randal wrote:


Comments and questions welcome as usual.

  +=head3 Hybrid solution
  +
  +Another option is to return a status object from each I/O operation.

I'm in favour of such a solution. There are several reasons:
- int status codes can't provide all the variety of information, we might want to return
- having variants that return exceptions too, leads to code duplication
- read operations can directly return the result string PMC

+The disadvantage is that a status object involves more overhead than a
  +simple integer status code.

Well, IO goes usually through several layers aka function calls, and isn't one of the fast operations a computer performs. And: - int status codes (if checked) are usually just converted to PMCs by HLL compilers - if PMC creation becomes a bottleneck, then we should fix it and not avoid or work around it

That said I can imagine to unify sync/async at the surface. E.g.

sync operation:

  PResult = Pio."read"(n)    # PResult = String/IOError object

async operation:

  PAsync = new .IOAsync, Pcallback
  PAsync."set_callback"(Pcb)   # or method
  ...
  Pio."async"(PAsync)
  PStatus = Pio."read"(n)

Both the sync and async read bubble down the layers until one is found that supports the operation either directly or by e.g. emulating async. But due to the same function call signature, we can avoid duplication of code paths.

Allison

leo

Reply via email to