Re: [TCLCORE] TIP #266: Numbers are Commands
by Peter MacDonald other posts by this author
Apr 12 2006 12:03PM messages near this date
Re: [TCLCORE] TIP #266: Numbers are Commands
|
Re: [TCLCORE] TIP #266: Numbers are Commands
I wonder if the tip might not benefit from more real world examples.
For example, presumably the normal usage would be to not throw away
the result, but rather:
set x [200 + 42]
That said, I'd have to agree that math is at best the adopted ugly step-child
of Tcl. An alternative might be to just tie into [unknown]. eg:
#################################
proc unknown {args} {
if {[string match {[-0-9.]*} $args]} {
return [expr $args]
}
error "unknown command: $args"
}
set x [200 + 42]
set y [-0.1*2.3]
puts "X,Y: $x,$y"
#################################
This gives more general support for floats and no spaces plus offers possible
backward compatibility. But of course, it still uses expr and ignores the
C-syntax complaints of the tip...
On April 12, 2006 08:16 am, Kristoffer Lawson wrote:
...
> /e.g./ to get 242 a simple addition can be made:
>
> 200 + 42
>
--
Peter MacDonald PDQ Interfaces Inc
Email: peter@[...].com http://pdqi.com
Phone: (250) 595-5998
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
Tcl-Core mailing list
Tcl-Core@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Thread:
Kristoffer Lawson
Arjen Markus
Peter MacDonald
Kristoffer Lawson
Peter MacDonald
Kristoffer Lawson
Peter MacDonald
Kristoffer Lawson
Arjen Markus
dgp
Arjen Markus
Brian Griffin
Peter MacDonald
Kristoffer Lawson
Gustaf Neumann
Donal K. Fellows
Donald G Porter
Neil Madden
David N. Welton
Arjen Markus
Kristoffer Lawson
Neil Madden
Kristoffer Lawson
Lars Hellström
Neil Madden
Kristoffer Lawson
|