|
From: Emiliano <emi...@gm...> - 2025-10-23 13:05:12
|
On Tue, 21 Oct 2025 08:02:55 +0000 Zaumseil René via Tcl-Core <tcl...@li...> wrote: > Hello > > I currently do not see the benefit of this proposal, except some char less to type. > IMHO expr has some problems or room for enhancements: > > 1. Double evaluation of arguments > > Could be solved with a new command with only 1 argument > > 1. Returns only one value > > See p.e. tip 647 syntax In case you are interested, I wrote a quick POC of tip 647, available at https://chiselapp.com/user/egavilan/repository/mexpr Sample usage: # 1 argument % package require mexpr 0.1 % ::mexpr::let { a {rand()} b {3*$a} b {sqrt($b)} } 0.6664191757638097 1.9992575272914292 1.4139510342623005 % list $a $b 0.6664191757638097 1.4139510342623005 # multiple arguments % ::mexpr::let a {rand()} b {3*$a} b {sqrt($b)} 0.5070870623491178 1.5212611870473536 1.2333941734284923 % list $a $b 0.5070870623491178 1.2333941734284923 # 1 argument, using -local % unset a b % ::mexpr::let -local { a {rand()} b {3*$a} b {sqrt($b)} } 0.20174559122032745 0.6052367736609824 0.7779696482903317 list $a $b can't read "a": no such variable # with -local, all referenced variables must be either defined first # or reached using their qualified name % set c 4 4 % ::mexpr::let -local b {3 * $c} can't read "c": no such variable % ::mexpr::let -local b {3 * $::c} 12 I've left out the magic variable names; all set values are collected and returned. Feel free to change and experiment. Regards -- Emiliano |