TIP 131: Read My Mind and Do What I Mean

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:		Joe English <jenglish@flightlab.com>
State:		Draft
Type:		Project
Vote:		No voting
Tcl-Version:	8.5
Created:	01-Apr-2003
Post-History:	

Abstract

A new Tcl command is proposed, rmmadwim. This is an acronym for ``Read My Mind and Do What I Mean_. This command has obvious utility.

Specification

The rmmadwim command shall take no arguments. When invoked, the Tcl interpreter shall read the programmer's mind and do what he or she intends.

NOTE: It is very important that rmmadwim read the programmer's mind, not the end user's. Otherwise the consequences could be disastrous, since end users rarely have a firm grasp of what the original programmer was up to.

As a consequence of this command, there is also a corresponding function for expr which applies the same principles to general mathematical computation:

  set result [expr {rmmadwim()}]

This extra functionality is easy to enable:

  rmmadwim

Rationale

What Tcl needs in order to succeed in the marketplace is a feature that no other programming language provides, a "killer app" as it were. The Tk toolkit, Expect, cross-platform portability, scripted documents, tkcon, and the [incr Tcl] "toaster" example are all well and good, but they have clearly failed to push Tcl usage to the point of having critical mass. The rmmadwim command would provide a powerful enough incentive that even Perl programmers would be compelled to switch languages.

Reference Implementation

A skeletal implementation is included below. Clearly some of the details remain to be flushed out, but this is a simple matter of programming (SMOP). It should be a fun weekend project for Richard Suchenwirth.

File: tcl/generic/tclCmdMZ.c

Function: Tcl_RmmAndDWIMObjCmd

       /*ARGSUSED*/
   int
   Tcl_RmmAndDWIMObjCmd(dummy, interp, objc, objv)
       ClientData dummy;                   /* Not used. */
       Tcl_Interp *interp;                 /* Current interpreter. */
       int objc;                           /* Number of arguments. */
       Tcl_Obj *CONST objv[];              /* Argument objects. */
   {
       int status;
       Tcl_Obj *intentions;

       if (objc != 1) {
           Tcl_WrongNumArgs(interp, 1, objv, NULL);
           return TCL_ERROR;
       }

       status = TclReadProgrammersMind(interp, &intentions);
       if (status != TCL_OK) {
           return status;
       }

       status = TclDoWhatIsMeant(interp, intentions);
       return status;
   }

Security Implications

It was pointed out that the ability to read the programmers' mind carries with it certain security and privacy implementations.

To address this, the following code should be executed whenever a safe interpreter is created:

   #
   # Query the programmer's mind to obtain his or her
   # P3P settings (See "Platform for Privacy Preferences",
   # <URL: http://www.w3.org/P3P >)
   #
       rmmadwim

   #
   # Disable any internal commands that are in conflict
   # with those settings:
   #
       rmmadwim

In addition, the Tcl release notes should give a clear indication to programmers about the new security implications for non-Safe interpreters.

Copyright

This TIP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License; either version 2 of the License, or (at Richard Stallman's discretion), any later version.

Just kidding. Public domain, as usual.

History