Stef, I do not doubt that the image is littered with such problems. On several occasions, I lost 10-15 minutes tracking down errors that resulted from unopened files. It is all a continuation of my streams "rant" (a well-intentioned one, of course).
Meaning no disrespect to the milestones (in particular, streams being slated for the future), I have undertaken an effort similar to what you propose: putting an end to silent failures and lack of protection. As a streams addict, I need stable semantics, and have thus embarked on my #nextOne, #nextMany:, etc. solution to reaching that goal. It also became clear that FileStream was quite unfriendly, so I started adding Dolphin-compatible methods, at least to a point. My primary goal is to have errors arise when appropriate vs. waiting for potentially/apparently disconnected collateral damage to occur. Dolphin's semantics will not be completely appropriate for Squeak, because there are OS (in)dependencies to consider. I want that to work well so I can treat my Redmond allergy. I urge Smalltalkers to avoid #next and #next: like the plague, but one could always use my changes and ignore the replacements. A very incomplete but gradually evolving change set is available on request. Bill Wilhelm K. Schwab, Ph.D. University of Florida Department of Anesthesiology PO Box 100254 Gainesville, FL 32610-0254 Email: [EMAIL PROTECTED] Tel: (352) 846-1285 FAX: (352) 392-7029 >>> [EMAIL PROTECTED] 07/18/08 3:40 AM >>> I was looking at the ensure: usage in the image. And I found this one (besides the third line :) and I was wondering if it would not make sense to check them all (ensure:, forceNewFileNamed:.....) because if forceNewFileNamed: returns nil the ensure will not work. writeEncoded: bytes | file | fileName ifNil:[^self]. false ifTrue:[^self]. file := FileStream forceNewFileNamed: fileName. [file nextPutAll: bytes] ensure:[file close]. I was also looking at readOnlyFileNamed: and it does not return nil readOnlyFileNamed: fileName "Open an existing file with the given name for reading." | fullName f | fullName := self fullName: fileName. f := self new open: fullName forWrite: false. ^ f isNil ifFalse: [f] ifTrue: ["File does not exist..." ((FileDoesNotExistException fileName: fullName) readOnly: true) signal]. "StandardFileStream readOnlyFileNamed: 'kjsd.txt' " I found some inconsistencies: For example BMPReadWriter>>nextPutImage: aForm as a stream close as the last messages while all the other methods do not and should be protected by an ensure: may be we could have a task for going over the implementation of fileStream and also the ensure: uses. Stef _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
