From: ouster@sprite.Berkeley.EDU (John Ousterhout)
Newsgroups: comp.lang.tcl
Subject: Planning for Tcl 7.0
Date: 8 Oct 1992 00:06:26 GMT
Organization: U.C. Berkeley Sprite Project
Distribution: world
NNTP-Posting-Host: tyranny.berkeley.edu


For the last year I've made only small changes to Tcl while focussing
on the canvas and text widgets for Tk.  I'm now making plans to catch
up on a bunch of much-needed bug fixes and enhancements to Tcl.  Some
of the changes I'm considering are not backwards-compatible.  The
purpose of this message is to let know know what changes I'm considering
for Tcl 7.0 and to solicit feedback.  I'm particularly interested in
comments on the changes that are incompatible:  I'll probably drop
the changes for which I get lots of negative feedback and not much
positive feedback.  If there are other changes that you think are
important but aren't contained on this list, let me know and I may add
them.

Incompatible changes:
---------------------

The changes listed below are likely to require changes to existing
scripts and/or C code.  Each change includes an explanation of why the
change might be useful.  I'd like to know whether or not you think the change
is useful enough to justify the incompatibility.

1. Eliminate the "|" option in the "open" command.  Instead, add a
"popen" command that does the same thing. Rationale: in the current
implementation you can't open a file whose name begins with "|".
Also, I think the "popen" command would be more logical.

2. Eliminate the Tcl_WaitPids procedure and use the waitpid POSIX call
instead.  Also change the wait code to periodically poll for dead
child processes so that zombie processes don't get left around forever.
Rationale: the current code tends to leave zombies around in some
situations.  Switching to waitpid should solve this problem in a
relatively portable fashion.  The only incompatibility will be for
C procedures that call Tcl_WaitPids;  they'll have to switch to call
waitpid instead.  I'll provide a compatibility version of waitpid for
use on systems that don't have it yet.

3. Clean up backslash processing in several ways:
    - Change backslash-newline to eat up all the whitespace following the
      newline and replace the sequence with a single whitespace character.
      Right now it only eats up the newline character and replaces it
      with an empty string.  Rationale:  this would be more consistent
      with other programs that process backslash-newline sequences.
    - Eliminate the sequences \Mxx, \Cxxx, and \e.
      Rationale: these sequences are left around from ancient times.
      They're not particular compatible with any other program.  I
      should have removed them in Tcl 6.0 but didn't.  They did get
      removed from the documentation, however, so no-one should be
      using them (?).
    - Change \x (where x is not one of the characters that gets special
      backslash treatment) to expand to x, not \x.
      Rationale: the current behavior is inconsistent with all other
      programs I know of that handle backslashes, and I think it's
      confusing.
    - Change "format" so it doesn't do an additional layer of backslash
      processing on its format string.
      Rationale:  I don't know why it currently behaves as it does, and
      I think it's confusing.

4. Change "regsub" so that when no match occurs it sets the result
variable to the original string, rather than leaving it unmodified.
Rationale:  the current behavior results in extra tests of the regsub
result that could sometimes be avoided with the proposed new behavior.
I doubt that there's much code that will break with the change (this
would have to be code that depends on the result variable *not* being
modified).

5. Change the name "UNIX" in the "errorCode" variable to "POSIX".
Rationale:  I suspect that I'm eventually going to get a call from the
USL lawyers on this one if I don't change it.  Better to change it now
in an orderly fashion so I don't have change it hastily in the future.

6. Change glob to return only the names of existing files.
Rationale:  at present "glob */foo" expands * and generates a result
without checking to see if each directory has a "foo" file in it.  This
makes the current behavior incompatible with csh, for example.  One
question is whether constructs like "glob {a,b}.c" should also check for
the existence of each of the files.  At present they don't (i.e. a.c and
b.c will be returned even if they don't exist), but neither does csh.  My
inclination is to make the behavior match csh (names containing *?[] are
checked for existence, others aren't).  I'd be interested to hear
opinions on this one:  check all names for existence, check only names
including *?[] (for csh compatibility), or keep it as it is?

7. Change "gets" so it returns 1 for success and 0 for failure.  At present
it returns the line length for success and -1 for failure.
Rationale: this would allow slightly simple Tcl scripts:  you could just
say
    while [gets $f line] {...}
instead of
    while {[gets $f line] >= 0} {...}
I'm not really convinced that this one is important enough to justify the
incompatibility, so it won't take much negative feedback to kill it.

Other changes:
--------------

The changes listed below shouldn't introduce substantial compatibility
problems.  Of course, any change can potentially cause scripts to stop
working (e.g. almost any change will break the test suite), but very
few if any people should be affected by these changes.

8. Implement Tcl_CreateExternVar() procedure along lines proposed by
Andreas Stolcke to tie a C variable to a Tcl variable with automatic
updates between them.

9. Changes to exec:
    - Allow redirection to an existing file descriptor in "exec",
      with a mechanism like >&1 or >& stdout.
    - Allow file names immediately after ">" and "<" without
      intervening spaces.

10. Changes related to files:
    - Fix Scott Bolte bug (closing stdin and stdout).
    - Move TclGetOpenFile and OpenFile stuff to tcl.h so that they're
      accessible to applications.
    - Extend access modes in open to include the complete set of POSIX
      access modes (such as O_EXCL and O_NONBLOCK).

11. Re-instate Tcl_WatchInterp to notify application when an interpreter
is deleted.

12. Add "elseif" mechanism to "if" command for chaining "else {if ..."
constructs more cleanly.  Require exact matches on "then" and "else"
keywords.

13. Remove UNIX system call declarations from tclUnix.h.  Use them from
unistd.h instead, and provide a default version of unistd.h for systems
that don't have one.

14. Changes in the expr command, mostly following suggestions made by
George Howlett a long time ago:
    - Increase precision of floating-point results.
    - Make floating-point numbers always print with a point.
    - Add transcendental functions like sin and exp.
    - Add explicit integer and floating conversion operations.
    - Don't promote large integers to floating-point automatically.
    - Allow multiple arguments to expr command.

15. Extend lsort to allow alternate sorting mechanisms, like numeric,
or client-supplied.

16. Allow alternate pattern-matching forms (e.g. exact or regexp) for
lsearch and case.

17. Add XPG/3 positional argument specifiers to format (code contributed
by Mark Diekhans).

18. Change "file readlink" to return an error on systems that don't
support it rather than removing the option entirely.

19. Add a mechanism for scheduling a Tcl command to be executed when the
interpreter reaches a clean point.  This is needed for things like
signal support.

20. Change upvar so that you can refer to an element of an array as
well as a whole array.
Newsgroups: comp.lang.tcl