[gambit-list] Parameter objects performance Q

Marc Feeley feeley at iro.umontreal.ca
Sun Mar 8 18:44:36 EDT 2020


> On Mar 8, 2020, at 12:39 PM, John Cowan <cowan at ccil.org> wrote:
> 
> All the examples I have found (except Marc's, thank you Marc) involve using parameters in exactly this way, which I why I am especially interested in other use cases.
> 

This situation can be generalized to any object whose methods take implicit parameters that depend on the thread and the object.

For example, imagine you have a class C with a method M, and you wish to generate debugging information whenever the current thread calls method M of obj, an instance of C.  You only want the debugging information to be generated for that combination of obj and the current thread (possibly because many other threads call method M on other instances of C without any problem).

So each instance of C could have a field with a “debug” parameter object that would be parameterized by any thread needing debugging information to be generated.

If parameter objects could only be bound to global variables you couldn’t have such a fine level of control.  First-class citizenship of parameter objects is very useful for scenarios like this.  Similarly to procedures and continuations gaining in power when they are first-class.

Marc





More information about the Gambit-list mailing list