Package gmisclib :: Module g_closure :: Class Closure
[frames] | no frames]

Class Closure

source code

Instance Methods
 
__init__(self, fcn, *argv, **kwarg)
Create a closure by memorizing a function and its arguments.
source code
 
__repr__(self) source code
 
__call__(self, *argv, **argd)
This evaluates the closure to either produce a value or raise an exception.
source code
 
partial(self, *argv, **argd)
This evaluates the closure to produce another (more complete) closure.
source code
 
defer(self, user)
This will call the specified function when the closure is completed.
source code
Method Details

__init__(self, fcn, *argv, **kwarg)
(Constructor)

source code 

Create a closure by memorizing a function and its arguments. If all arguments are supplied, you can get the result by calling the closure without arguments. Missing arguments are replaced by instances of class NotYet; such arguments will need to be supplied when the closure is called.

As an additional feature, you can supply a list of users of the function's value. When the value is (eventually) produced, the user function(s) will be called with the closure's return value. Users must be functions of one argument.

partial(self, *argv, **argd)

source code 

This evaluates the closure to produce another (more complete) closure. Users are not preserved.

defer(self, user)

source code 

This will call the specified function when the closure is completed. It's a bit of a kluge.