TIP #174 Version 1.12: Math Operators as Commands

This is not necessarily the current version of this TIP.


TIP:174
Title:Math Operators as Commands
Version:$Revision: 1.12 $
Authors: Kristoffer Lawson <setok at altparty dot org>
Donal K. Fellows <donal dot k dot fellows at man dot ac dot uk>
David S. Cargo <escargo at skypoint dot com>
Peter Spjuth <peter dot spjuth at space dot se>
Kevin B. Kenny <kennykb at acm dot org>
State:Draft
Type:Project
Tcl-Version:8.5
Vote:Pending
Created:Monday, 15 March 2004

Abstract

This TIP describes a proposal for math operators in Tcl as separate commands, acting much like the equivalent in the Lisp language. This would make simple usage of mathematics much clearer.

Rationale

While the expr command works fairly well for longer mathematical expressions, it is extremely tedious for the most common uses, such as handling indices. Take the following examples:

 set newList [lrange $list [expr {$idx - 5}] [expr {$idx + 5}]]
 .c create oval [expr {$x - $r}] [expr {$y - $r}] [expr {$x + $r}] [expr {$y + $r}]

Many find this particular aspect of Tcl unappealing. It gets increasing