Spin.hold

From OpenEUO
Revision as of 16:24, 8 January 2011 by Ximan (Talk | contribs) (See Also)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Calling Pattern

Call

local r = sl.spin(a[, b[, ...]])

later

local v,t = r.hold([c[, ...]])

Args

c0..cN are an indefinite number of variadic arguments of any type

Results

v is any type
t is a number

Description

The spin hold method repeatedly calls (around 10 calls per second) the function a passed to the spin constructor until such time as it returns a non-nil value.

At each cycle of evaluation, hold supplies its variadic arguments to all of the functions b0...bM passed to the constructor and evaluates them. The first result of each is passed as an argument to a in the same order. Then c0...cN round out the remainder of arguments passed to function a. E.g.,

v = a([b0([c0,...cN]),...bM([c0,...cN])][, c0,...cN])

If a b is encountered which is not a function, it is simply passed as value, unless it is nil in which case it is converted to null first.

Hold evaluates at least one cycle, and terminates upon any non-nil result v. The time elapsed during the hold operation, t, is passed back as well.

Upon Error

If one of the passed functions throws an error during evaluation, an unhandled exception will occur. In version 0.06, any errors thrown will be caught at the spin.hold level and handled according to the operant error redirection mode.

See Also