From: Martin Jansson Date: 2006-07-23T07:34:26+09:00 Subject: Set an instance variable before and after initialize If possible, I would like to set a instance variable in an object before and after its initialize method is executed. I've been looking at Class#new but it doesn't seem to have access to a reference to the object in creation. A possible workaround would be to place the object in an already created hashtable. But I need to know if initialize has been completed or not even if callcc is used. This behavior must be shared by all objects in classes that inherit Object. I try to create Simula style corutines. In Simula all objects have three states of execution: active, passive and terminated. An active object is executing it's class body (think: Rubys Object#initialize on steroids). The first time an object is activated is when it's created with new. Within the class body you can call detach to make the object passive and pause execution of the class body. Execution is then continued after the point where the object was last activated. Within the class body you can also call resume wich make the object passive and activates another object. Execution is continued again when the other object become passive or terminated. Objects can also become active if the procedure call is called with the object as an argument. When execution reach the end of the objects class body, the object becomes terminated and can not be activated anymore. You can't do all the things you can do with callcc with this kind of corutines but it makes some otherwise hairy programming easy. -- Posted via http://www.ruby-forum.com/.