<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://www.tcl.tk/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Sun May 19 18:42:39 GMT 2013 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='131'>
<header><title>Read My Mind and Do What I Mean</title><author address="mailto:jenglish@flightlab.com">Joe English</author><status type='project' state='draft' tclversion="8.5" vote='none'>$Revision: 1.2 $</status><history></history><created day='1' month='apr' year='2003' /></header>
<abstract>A new Tcl command is proposed, <emph style="italic">rmmadwim</emph>. This is an acronym for ``Read My Mind and Do What I Mean&apos;&apos;. This command has obvious utility.</abstract>
<body><section title="Specification">
<para>The <emph style="italic">rmmadwim</emph> command shall take no arguments. When invoked, the Tcl interpreter shall read the programmer&apos;s mind and do what he or she intends.</para>
<para><emph style="italic">NOTE:</emph> It is very important that <emph style="italic">rmmadwim</emph> read the <emph style="italic">programmer&apos;s</emph> mind, not the end user&apos;s. Otherwise the consequences could be disastrous, since end users rarely have a firm grasp of what the original programmer was up to.</para>
<para>As a consequence of this command, there is also a corresponding function for <emph style="italic">expr</emph> which applies the same principles to general mathematical computation:</para>
<verbatim><vline encoding='base64'>ICBzZXQgcmVzdWx0IFtleHByIHtybW1hZHdpbSgpfV0=</vline></verbatim>
<para>This extra functionality is easy to enable:</para>
<verbatim><vline encoding='base64'>ICBybW1hZHdpbQ==</vline></verbatim>
</section>
<section title="Rationale">
<para>What Tcl needs in order to succeed in the marketplace is a feature that no other programming language provides, a &quot;killer app&quot; as it were. The Tk toolkit, Expect, cross-platform portability, scripted documents, tkcon, and the [incr Tcl] &quot;toaster&quot; example are all well and good, but they have clearly failed to push Tcl usage to the point of having critical mass. The <emph style="italic">rmmadwim</emph> command would provide a powerful enough incentive that even Perl programmers would be compelled to switch languages.</para>
</section>
<section title="Reference Implementation">
<para>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.</para>
<para>File: <emph style="italic">tcl/generic/tclCmdMZ.c</emph></para>
<para>Function: <emph style="italic">Tcl_RmmAndDWIMObjCmd</emph></para>
<verbatim><vline encoding='base64'>ICAgICAgIC8qQVJHU1VTRUQqLw==</vline><vline encoding='base64'>ICAgaW50</vline><vline encoding='base64'>ICAgVGNsX1JtbUFuZERXSU1PYmpDbWQoZHVtbXksIGludGVycCwgb2JqYywgb2Jqdik=</vline><vline encoding='base64'>ICAgICAgIENsaWVudERhdGEgZHVtbXk7ICAgICAgICAgICAgICAgICAgIC8qIE5vdCB1c2VkLiAqLw==</vline><vline encoding='base64'>ICAgICAgIFRjbF9JbnRlcnAgKmludGVycDsgICAgICAgICAgICAgICAgIC8qIEN1cnJlbnQgaW50ZXJwcmV0ZXIuICov</vline><vline encoding='base64'>ICAgICAgIGludCBvYmpjOyAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIE51bWJlciBvZiBhcmd1bWVudHMuICov</vline><vline encoding='base64'>ICAgICAgIFRjbF9PYmogKkNPTlNUIG9ianZbXTsgICAgICAgICAgICAgIC8qIEFyZ3VtZW50IG9iamVjdHMuICov</vline><vline encoding='base64'>ICAgew==</vline><vline encoding='base64'>ICAgICAgIGludCBzdGF0dXM7</vline><vline encoding='base64'>ICAgICAgIFRjbF9PYmogKmludGVudGlvbnM7</vline><vline encoding='base64'></vline><vline encoding='base64'>ICAgICAgIGlmIChvYmpjICE9IDEpIHs=</vline><vline encoding='base64'>ICAgICAgICAgICBUY2xfV3JvbmdOdW1BcmdzKGludGVycCwgMSwgb2JqdiwgTlVMTCk7</vline><vline encoding='base64'>ICAgICAgICAgICByZXR1cm4gVENMX0VSUk9SOw==</vline><vline encoding='base64'>ICAgICAgIH0=</vline><vline encoding='base64'></vline><vline encoding='base64'>ICAgICAgIHN0YXR1cyA9IFRjbFJlYWRQcm9ncmFtbWVyc01pbmQoaW50ZXJwLCAmaW50ZW50aW9ucyk7</vline><vline encoding='base64'>ICAgICAgIGlmIChzdGF0dXMgIT0gVENMX09LKSB7</vline><vline encoding='base64'>ICAgICAgICAgICByZXR1cm4gc3RhdHVzOw==</vline><vline encoding='base64'>ICAgICAgIH0=</vline><vline encoding='base64'></vline><vline encoding='base64'>ICAgICAgIHN0YXR1cyA9IFRjbERvV2hhdElzTWVhbnQoaW50ZXJwLCBpbnRlbnRpb25zKTs=</vline><vline encoding='base64'>ICAgICAgIHJldHVybiBzdGF0dXM7</vline><vline encoding='base64'>ICAgfQ==</vline></verbatim>
</section>
<section title="Security Implications">
<para>It was pointed out that the ability to read the programmers&apos; mind carries with it certain security and privacy implementations.</para>
<para>To address this, the following code should be executed whenever a safe interpreter is created:</para>
<verbatim><vline encoding='base64'>ICAgIw==</vline><vline encoding='base64'>ICAgIyBRdWVyeSB0aGUgcHJvZ3JhbW1lcidzIG1pbmQgdG8gb2J0YWluIGhpcyBvciBoZXI=</vline><vline encoding='base64'>ICAgIyBQM1Agc2V0dGluZ3MgKFNlZSAiUGxhdGZvcm0gZm9yIFByaXZhY3kgUHJlZmVyZW5jZXMiLA==</vline><vline encoding='base64'>ICAgIyA8VVJMOiBodHRwOi8vd3d3LnczLm9yZy9QM1AgPik=</vline><vline encoding='base64'>ICAgIw==</vline><vline encoding='base64'>ICAgICAgIHJtbWFkd2lt</vline><vline encoding='base64'></vline><vline encoding='base64'>ICAgIw==</vline><vline encoding='base64'>ICAgIyBEaXNhYmxlIGFueSBpbnRlcm5hbCBjb21tYW5kcyB0aGF0IGFyZSBpbiBjb25mbGljdA==</vline><vline encoding='base64'>ICAgIyB3aXRoIHRob3NlIHNldHRpbmdzOg==</vline><vline encoding='base64'>ICAgIw==</vline><vline encoding='base64'>ICAgICAgIHJtbWFkd2lt</vline></verbatim>
<para>In addition, the Tcl release notes should give a clear indication to programmers about the new security implications for non-Safe interpreters.</para>
</section>
<section title="Copyright">
<para>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&apos;s discretion), any later version.</para>
<para>Just kidding. Public domain, as usual.</para>
</section>
</body></TIP>
