Re: [Rd] Saving nothing with save()

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Tue, 20 Dec 2011 19:40:15 +0100

>>>>> Simon Urbanek <simon.urbanek_at_r-project.org> >>>>> on Mon, 19 Dec 2011 10:38:34 -0500 writes:

    > Martin, On Dec 19, 2011, at 6:39 AM, Martin Maechler     > wrote:

    >>>>>>> Barry Rowlingson <b.rowlingson_at_lancaster.ac.uk> on
    >>>>>>> Sun, 18 Dec 2011 01:32:52 +0000 writes:

>>
    >>> Scenario: Here I am working away in R. I've got results
    >>> that prove global warming is anthropogenic and also the
    >>> solution for producing limitless carbon-neutral energy
    >>> from nuclear fusion. Its been a good day.

>>
    >>> So, I want to save my work. I don't want to overwrite my
    >>> current .RData, so I save it to another file:

>>
    >>> save(file="prize.RData") # just need to email this to
    >>> the Nobel committee q() Save workspace image? [y/n/c]: -
    >>> "no" I don't want to save the workspace image, I just
    >>> saved everything to "prize.RData". But gee, it did seem
    >>> to do that quite quickly considering the volume of
    >>> evidential data in my work. My unix shell prompt
    >>> returns.

>>
    >>> Uh oh. See what I did there? I typed 'save' when I meant
    >>> 'save.image'.  What does that give me?

>>
    >>> A 42 byte, empty, latest.RData, and because there was no
    >>> warning or error I quit without saving it
    >>> again. Oops. Massive Data Loss.

>>
    >>> Is there any reason why save(file="file.RData") couldn't
    >>> warn or error if you try and save nothing? There's no
    >>> obvious check in the R code for save.

>>
    >>> Barry

>>
    >>> PS the above scenario is fictional.

>> really? ;-)
>>
>> well, after *not* save()ing all your findings, it
>> wouldn't have been such a good day, would it?
>>
>> well, in spite of that. I agree that save() should warn
>> or stop in that case. I have now committed a version --
>> to R-devel only -- which stop()s if 'pretest=TRUE' and
>> uses warning() otherwise,

    > I don't think I like that - why should it warn/stop in any     > case even when the use is absolutely legal?

    > I think this is the wrong approach - the whole idea was to
    > warn on unintended *interactive* use - breaking existing
    > code in the process is IMHO not necessary. I don't think
    > save(list=x, file=y) should fail even if x is empty - that
    > makes it fail for completely legal code. What Barry was
    > worried about was the interactive case of save(file=x)
    > which should IMHO warn (there is a precedent for stopping
    > as well - see tar - so I won't object).

    > I really see no reason for adding the pretest flag - it
    > makes no sense since is warns anyway so it doesn't help at
    > all. I would propose changing *only* the behavior of
    > save(file=x) (to warn or stop - personally I prefer     > former) and not anything else.

hmm

>> e.g., in the case of save.image() when there's nothing to
>> save.
>>

    > Why should save.image() warn? Again, it causes unnecessary
    > trouble for automated saving... empty workspace is
    > probably even more common that using save(file=foo) ... If
    > save() was fixed as above, that would be a non-issue.

warning in that case actually *was* a bit intentional: I think too many people work with '.Rdata' etc ... and I always use --no-save --no-restore.

But then, you are right. If we'd want to change that behavior that should be tried differently...

I've now changed the patch to only warn and only in the case when the 'list' argument is missing(.).

Martin

>> Thank you, Barry. for the suggestion!

    > Well, you did not follow his suggestion, though ;)

    > Cheers, Simon

>> Martin
>>

    >>> When did I last have a good day?

>>
>> (I wish you more of those..)
>>
>> ______________________________________________
>> R-devel_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>

    >>

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 20 Dec 2011 - 18:43:08 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 22 Dec 2011 - 16:10:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive