Stef, I agree you are improving on the existing code, but I would prefer something like file := fd readOnlyFileNamed:name ifNone:[ ^self ]. This is analogous to #at:ifAbsent:, which does not set up an exception handler and raise and handle an exception for something that is known to be handled locally. Then, just as #at: _does_ raise an exception, there should be readOnlyFileNamed:aBlock ^self readOnlyFileNamed:name ifNone:[ FileDoesNotExist signalWith:name. ]. #signalWith: might not be the correct syntax (too tired to look<g>), but hopefully it makes the point that exceptions should be raised, but there should also be "long winded" methods that skip the overhead when it is possible to do so. Bill Wilhelm K. Schwab, Ph.D. University of Florida Department of Anesthesiology PO Box 100254 Gainesville, FL 32610-0254 Email: bschwab@anest.ufl.edu Tel: (352) 846-1285 FAX: (352) 392-7029
stephane.ducasse@inria.fr 08/11/08 4:15 PM >>>
update10052 ISSUE #124 While browsing at referencer of FileDoesNotExistException, I discovered the following pattern that is used in many different places. I find this pretty ugly: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= file := [fd readOnlyFileNamed: keysFileName] on: FileDoesNotExistException do:[:ex| nil]. file ifNil:[^self]. "no keys file" -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The use of exception is completely outwitted. I would rather write: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [file := fd readOnlyFileNamed: keysFileName] on: FileDoesNotExistException do: [:ex| ^ self]. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=