Changing current ContextSubclasses of Element use special preamble in all their non-static methods, except for a few special ones and getters. This is not required for methods which don't have any arguments and return type of Element class (or its subclasses) - @TODO check; fix the following:Element method( Element arg1, Element arg2... ) { if( entered( argX ) ) { return up( method( dw( arg1 ), dw( arg2 )... ) ); } // do the actual task... } where
argX in expression entered( argX ) must not be null, because it can't be determined whether null entered from the same of upper Context. There can be methods other than getters which don't have any Element arguments, but return an Element. These can't employ this mechanism. Their returned Element must be adjusted in place where they are called. If possible, provide External and Internal version of the method. In common cases, External method calls Internal one, and then unwounds the result using up(). An alternative to function header - automated per-thread Context. It would trail method call stack in the way describe above. Its features
Elements, static (global) variables and non-Element containersElements may be freely stored as normal objects. They can be in static variables, collections and objects which don't support Elements. However, when retrieved from there, they may be not compatible with current Context.Static Elements are ordinarily used for seeds only. Seeds use top-level "empty" Context. Before used, they are adapted to local Context using a special method. |
|
|
Copyright (c) 2005, 2006, 2007 Peter Kehl |