TIP #133 Version 1.1: Extending [expr] Operators

This is not necessarily the current version of this TIP.


TIP:133
Title:Extending [expr] Operators
Version:$Revision: 1.1 $
Author:Richard Suchenwirth <Richard dot Suchenwirth-Bauersachs at siemens dot com>
State:Draft
Type:Project
Tcl-Version:8.5
Vote:Pending
Created:Tuesday, 08 April 2003

Abstract

This TIP proposes a way to define new operators for conditions and the [expr] command. It also includes demonstrations of how it might work in the examples: in tests inclusion in a list, and and, or, and not are aliases for "&&", "||", "!".

Rationale

Inclusion of a value in a list is frequently tested with the construct

   if {[lsearch -exact $list $value] >= 0} {...}

The proposal, first brought by Reinhard Max in the Tcl Chatroom, is to allow an in operator in the language understood by [expr], and the condition parts of [for], [if] and [while], so that the above can be written as

   if {$value in $list} {...}

This is shorter to