[Pharo-project] Reference temporary variable of method ( or other solution )
Hi, i work with Pharo and GLASS. My question is relative to reference method variable define in the method. If i have methodA: methodA | var1 | var1 := 'this is an string'. self methodB. and methodB: methodB | a b c | a := 'a'. ......... i can now at this step reference the var1 defined in methodA ? I think it's in the stack or i wrong ? It's no elegant do it ? a need call self methodB: var1 The question is because i have some class for manage database and i will don't add istances variable to manage the operations on it. With this reference i can solve the problem without pass variables from some methods to other methods. If i found in the stack the specific reference i can manage some operations based on it. Any other indications to solve this problematic ? Thanks, Dario
Hi Dario, On Thu, Jul 28, 2011 at 5:11 PM, Dario Trussardi <dario.trussardi@tiscali.it> wrote:
Any other indications to solve this problematic ?
looking for a temporary variable is probably possible but not elegant. It also means that only methodA can call methodB. There are multiple solutions: - add an instance variable (but you don't like it) - add a parameter to methodB (but you don't like it) - create a dedicated class with with just var1 as instance variable and methodA and methodB as methods. -- Damien Cassou http://damiencassou.seasidehosting.st "Lambdas are relegated to relative obscurity until Java makes them popular by not having them." James Iry
participants (2)
-
Damien Cassou -
Dario Trussardi