ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> tcl-core
tcl-core
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved