On Wed, 1 Feb 2006, Mauricio Fernandez wrote:

> On Wed, Feb 01, 2006 at 12:32:57PM +0900, Brian Buckley wrote:
>> My questions:
>> 1  What is causing this error? (possibly Windows related?)
>
> IIRC File.read(file) doesn't open the file in binary mode; try
> File.open(file, "rb"){|f| f.read}
>
>> 2  What is the purpose of the rescue{} suppressing the error info in the
>> first place?
>
> setting cache to {} if Marshal.load fails for some reason (e.g. a major
> change in the Marshal format across Ruby versions).
>
>> 3  Instead of using Marshall would using yaml be a reasonable alternative?
>> (I am thinking of readability of the cache file and also capability to
>> pre-populate it)
>
> I wouldn't do that:
> * Marshal is faster than Syck (especially when dumping data)
> * YAML takes more space than Marshal'ed data
> * there are still more bugs in Syck than in Marshal (the nastiest memory
>  issues are believed to be fixed, but there is still occasional data
>  corruption)
> * Marshal is more stable across Ruby releases
>
> As for editing the cache, you can always do
> File.open("cache.yaml", "w") do |out|
>   YAML.dump(Marshal.load(File.open("cache", "rb"){|f| f.read}), out)
> end

why not pstore - it's done all that already and is built-in?

-a

-- 
happiness is not something ready-made.  it comes from your own actions.
- h.h. the 14th dali lama