Fixing up state after error

Joshua 'Schwa' Gargus schwa at cc.gatech.edu
Tue Aug 19 21:58:18 UTC 2003


That's the one I was looking for, I just couldn't remember the
incantation.

Thanks Ned!
Joshua


On Tue, Aug 19, 2003 at 02:21:31PM -0700, Ned Konz wrote:
> On Tuesday 19 August 2003 11:56 am, Joshua 'Schwa' Gargus wrote:
> > Hi,
> >
> > I'm pretty sure that that there's a way do what I want, but I can't
> > find it.
> >
> > Here's a simplified version of my problem: I have an object that
> > wants to save itself on a ReferenceStream in response to
> > #writeToFile, but it has some property stored in an instVar named
> > 'prop' that I don't want stored (I later store it separately).
> >
> > I have something like:
> >
> > writeToFile
> >
> > 	| propHolder |
> >
> > 	ref := ReferenceStream on: (FileStream fileNamed: 'output.obj').
> > 	propHolder := prop.
> > 	prop := nil.
> > 	ref nextPut: self.
> > 	prop := propHolder
> >
> >
> > I want to assure that if something goes wrong during stream
> > writing, and triggers a walkback, that 'prop' gets restored to its
> > old value.  I'm pretty sure I saw somthing like this recently in
> > the image, but can't remember where.
> 
> Why not just:
> 
> propHolder := prop.
> prop := nil.
> [ ref nextPut: self ] ensure: [ prop := propHolder ]
> 
> -- 
> Ned Konz
> http://bike-nomad.com
> GPG key ID: BEEA7EFE
> 



More information about the Squeak-dev mailing list