Donal K. Fellows | 23 Sep 17:32
Favicon

TIPs I'd like to see done

Now that we're through the big TIP vote, we should also consider which
of the other TIPs in Draft ought to have a little TLC applied to them so
we can vote them in. This is _my_ selection...

   #97:  Moving Vertices of Canvas Items
   #154: Add Named Colors to Tk
   #160: Improvements to Terminal and Serial Channel Handling
   #161: Change Default for Menu's -tearoff Option to False
   #162: IPv6 Sockets for Tcl                               (possibly...)
   #164: Add Rotate Subcommand to the Canvas Widget
   #166: Reading and Writing the Photo Image Alpha Channel
   #180: Add a Megawidget Support Core Package
   #210: Add 'tempname' Subcommand to 'file'
   #228: Tcl Filesystem Reflection API
   #234: Add Support For Zlib Compression
   #244: PNG Photo Image Support for Tk
   #262: Background Images for Frames
   #276: Specify and Unify Variable Linking Commands
   #281: Improvements in System Error Handling
   #301: Split Bidirectional Channels For Half-Close        (possibly...)
   #324: A Standard Dialog For Font Selection               (possibly...)

Note that I think each of them needs some work, whether providing an
implementation or fixing the proposed specification. If they were ready,
I'd have CFVed them already...

Donal.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
(Continue reading)

Joe English | 24 Sep 20:18

TIP#210 'file tempname' (was Re: TIPs I'd like to see done)


Donal K. Fellows wrote:
>
> Now that we're through the big TIP vote, we should also consider which
> of the other TIPs in Draft ought to have a little TLC applied to them so
> we can vote them in. This is _my_ selection...
> 
>    [...]
>    #210: Add 'tempname' Subcommand to 'file'

This one is almost but not quite right.

It specifies the syntax:

	file tempfile ?template? ?namevar?

which creates a unique temporary file and returns an open
file handle; if ?template? is specified it is used as the
path prefix and if ?namevar? is specified then the resultant
filename is stored there.

The order of the arguments is precisely backwards.

You almost always want to get the filename back,
so you can [file delete] it when you're through,
but you almost never want to specify the template 
(which might be [file join { $env(TMPDIR) or $env(TEMP) 
or $env(TMP) or the value of P_tmpdir or "/tmp" or "/var/tmp" 
or "/usr/tmp" on Unix; or %TEMP% or "C:\Windows\Temp" or 
ShGetKnowFolderPath(mumble) or ... dunno? on Windows }
(Continue reading)

Reinhard Max | 24 Sep 21:41

Re: TIP#210 'file tempname' (was Re: TIPs I'd like to see done)

Hi,

On Wed, 24 Sep 2008 at 20:18, Joe English wrote:

> but you almost never want to specify the template

I instantly came up with two reasons why one might want to specify the 
template in almost all cases:

1. If you use [file tempname] to create a file that is really
    temporary, it should have a prefix that identifies the creating
    application to simplify finding the origin of leaked temp files.

2. If you use a temporary file name for creating and populating a file
    so that it can come to existance under its final name as an atomic
    operation via [file rename], you want to do that somewhere near the
    location of the final file rather than in one of the standard temp
    locations so that the rename doesn't cross file system boundaries.

For #1 it might be desirable to be able to just give a prefix for the 
file name, but let the implementation figure out the directory to 
place it in.

So, if there are valid resons for all arguments to be optional 
independently of each other, I guess that calls for making them 
options rather than positional parameters, and maybe to split the 
template argument into directory and prefix for full orthogonality:

   file tempname ?-prefix prefix? ?-directory dir? ?-namevar var?

(Continue reading)

Larry McVoy | 24 Sep 22:18
Favicon

Re: TIP#210 'file tempname' (was Re: TIPs I'd like to see done)

On Wed, Sep 24, 2008 at 09:41:10PM +0200, Reinhard Max wrote:
> Hi,
> 
> On Wed, 24 Sep 2008 at 20:18, Joe English wrote:
> 
> > but you almost never want to specify the template
> 
> I instantly came up with two reasons why one might want to specify the 
> template in almost all cases:
> 
> 1. If you use [file tempname] to create a file that is really
>     temporary, it should have a prefix that identifies the creating
>     application to simplify finding the origin of leaked temp files.

Yes, so make the interface look at argv[0] and get it from there.
You own the tcl source so you can remember what the application
name is in a global and get it later.  We do this in bk for 
precisely this reason.  

> 2. If you use a temporary file name for creating and populating a file
>     so that it can come to existance under its final name as an atomic
>     operation via [file rename], you want to do that somewhere near the
>     location of the final file rather than in one of the standard temp
>     locations so that the rename doesn't cross file system boundaries.

Yup, we have a bktmp() that puts the file in the current repository
under BitKeeper/tmp for this reason.

Good points.
--

-- 
(Continue reading)

Arjen Markus | 25 Sep 09:15
Favicon

Re: TIP#210 'file tempname' (was Re: TIPs I'd like to see done)

Larry McVoy wrote:
On Wed, Sep 24, 2008 at 09:41:10PM +0200, Reinhard Max wrote:
Hi, On Wed, 24 Sep 2008 at 20:18, Joe English wrote:
but you almost never want to specify the template
I instantly came up with two reasons why one might want to specify the template in almost all cases: 1. If you use [file tempname] to create a file that is really temporary, it should have a prefix that identifies the creating application to simplify finding the origin of leaked temp files.
Yes, so make the interface look at argv[0] and get it from there. You own the tcl source so you can remember what the application name is in a global and get it later. We do this in bk for precisely this reason.
2. If you use a temporary file name for creating and populating a file so that it can come to existance under its final name as an atomic operation via [file rename], you want to do that somewhere near the location of the final file rather than in one of the standard temp locations so that the rename doesn't cross file system boundaries.
Yup, we have a bktmp() that puts the file in the current repository under BitKeeper/tmp for this reason. Good points.
Just a warning about the implementation (but I am sure you folks know more
about these matters than I do):
I have had trouble with the default tmpfile() function on Windows (XP) from
MS VC/C++ 6.0 (ancient, I know). The program ran on a network disk and
I could not write in the disk's root. The tmpfile() function however tried to
open a file x:\something, so in the root! and failed. In the end I replaced it
by a function that gave me more control over where precisely the file is
located.

Regards,

Arjen
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tcl-Core mailing list
Tcl-Core@...
https://lists.sourceforge.net/lists/listinfo/tcl-core
Rene Zaumseil | 26 Sep 08:06
Favicon

TIP#210 'file tempname'

Arjen Markus wrote:
> Just a warning about the implementation (but I am sure you folks know more
> about these matters than I do):
> I have had trouble with the default tmpfile() function on Windows (XP) from
> MS VC/C++ 6.0 (ancient, I know). The program ran on a network disk and
> I could not write in the disk's root. The tmpfile() function however 
> tried to
> open a file x:\something, so in the root! and failed. In the end I 
> replaced it
> by a function that gave me more control over where precisely the file is
> located.
Also do not forget the mkstemp() bug #878333 of IRIX systems.
Until now you have to manually patch tcl to create tclkit interpreters.

rene

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane