From: Robert Klemme Date: 2005-09-23T17:51:40+09:00 Subject: Re: static local variables jdm wrote: > i'm trying to create what C calls a static local variable inside a > particular method, i.e. this variable should not be visible outside > the method and its value should survive the activation of the method. > > instance variables are "static" but visible to all methods of the > instance. > > local variables are visible only to a particular method but aren't > "static". > > i've been through the pickaxe book and nothing obvious popped out at > me. it seems i could synthesize the desired functionality using > singleton methods attached to a particular instance (or maybe by > defining a block within the method) but i'm hoping there's a simpler, > cleaner way. > > thanx in advance. Just don't do it. As you see attempts to simulate this queer feature of C soon get ugly and bloated. If you need something like this rather think about command pattern (i.e. basically you create a class for a single, usually complex task). Kind regards robert