Updated 2017-05-19 20:43:35 by ak

What is a file handle? This is one of the various kinds of Tcl handles which is returned by Tcl commands such as open, [add other commands here that return this type of thing - perhaps relating to sockets, channels, other?]

They are a symbolic representation of an underlying operating system construct that represents an open input or output file/device. Examples:
 set    handle  [open $filename w]
 puts  $handle  $line
 close $handle

The Tcl man pages use the term channel.

Unix calls the underlying construct a file descriptor.

MHo 2017-05-19: I noticed that file handles are "recycled", so if a specific handle is closed, short after that a newly opened file gets the same handle.

ak - 2017-05-19 20:43:35

That is, I believe, because of unix recycling the underlying file descriptor. I am not sure if it applies to Windows as well. The recycling of the standard channels OTOH is something Tcl does by itself IOW
  close stdout
  open some/file

The channel for some/file now is "stdout". Works for sockets, pipes, etc. The first new channel after closing one of stdout, stderr, stdin becomes that channel.