From: mental@... Date: 2006-01-26T00:34:51+09:00 Subject: Re: LazyLoad Quoting Erik Veenstra : > > Will normal code be able to distiguish exceptions raised by > > implicitly evaluated code at random locations from those > > which are expected? > > I don't get this. Can you please explain a bit more > specifically, please? For example (not a great example, but hopefully you'll get a feel for the issue): MAPPING = lazy { Hash[*File.read( 'mapping.txt' ).map { |line| line.chomp.split } ].freeze } ... data = nil begin File.open( 'data.txt', 'r' ) { |stream| data = stream.map { |line| MAPPING[line.chomp] } } rescue Errno::ENOENT # create initial data.txt if it doesn't exist File.open( 'data.txt', 'w' ) { |stream| MAPPING.keys.each { |key| stream.puts key } } data = MAPPING.values end Nuking data.txt is probably not the right response to a missing mapping.txt... -mental