[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tempname vs. tmpnam
From: |
Rik |
Subject: |
Re: tempname vs. tmpnam |
Date: |
Wed, 22 Oct 2014 11:35:04 -0700 |
On 10/22/2014 11:15 AM, Daniel J Sebald wrote:
> On 10/22/2014 12:50 PM, Rik wrote:
>> 10/22/14
>>
>> All,
>>
>> I checked in a changeset which moves all of core Octave to using tempname
>> (http://hg.savannah.gnu.org/hgweb/octave/rev/6ca096827123).
>>
>> It doesn't actually deprecate tmpnam, but it removes it from seealso links
>> in the documentation and from the manual. If you type 'help tmpnam' it
>> returns a help string which mentions that tempname is preferred in new
>> code.
>>
>> Eventually we may fully deprecate it, but not for a while.
>
> What about "tmpfile"? It seems odd to have "tempname", "tempdir" and
> then "tmpfile". But I could see keeping "tmpfile" if there is a clear
> explanation as to why it should be that way. "tmpfile" is similar to
> "tempname" with the extra step of actually opening the file...but not
> quite the same. "tmpfile" does not have the option of a DIR so does that
> mean that files from "tmpfile" reside in the "/tmp" directory? Is that
> justification for calling it "tmpfile"? Options would be
>
> 1) Leave as is, with perhaps an explanation for why "tmp" rather than
> "temp".
>
> 2) Similar to "tmpnam"/"tempname", rename to "tempfile" and deprecate
> "tmpfile".
>
> 3) Create a "tempfile" perhaps having the same input options as
> "tempname" (and probably consist of calling tempname() and then adding a
> few lines of code to attempt opening the file). Rename "tmpfile" to
> "P_tmpfile".
>
> ??
>
tempdir and tempname are required for Matlab compatibility. The Mathworks
doesn't have a tempfile so we are free to do what we wish in this regard.
Right now, the name accords with the underlying C function name. But it
could make sense to settle on "temp" as the prefix for all temporary things
and rename this to tempfile. It would make it easier from the command line
to use temp<TAB> to see what functions are available. On the other hand,
tmpfile is in all the seealso links so if you're searching you will come
across it quickly.
Anyways, I'm not too exercised either way. If someone wants to prepare a
changeset I'd review it. Otherwise it can stay this way.
Cheers,
Rik