I'm now thinking about those places like lindex where an argument is
end-2 and stuff like that.
That's a DSL that could do with being generalised.
The message body is Copyright (C) 2025 Tristan Wibberley except
citations and quotations noted. All Rights Reserved except as noted in
the sig.
Regarding your concern about why there are various ways to use a variable:
see man tcl if on linux and read and understand the 12 rules in details, experiment based on what you find there.
Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk> posted:
I'm now thinking about those places like lindex where an argument is
end-2 and stuff like that.
That's a DSL that could do with being generalised.
In the Discussion section of TIP 676 I said:
Some of the string and list-related commands already support a restricted
form of numeric expressions for indices, e.g. [lindex $list end-2]. This
could be generalised in future by having them temporarily define end as
the appropriate value and run the = processing on index arguments.
While there are Tcl
commands that currently accept a variable name or a variable value, you cannot mix and match them willy-nilly. But the proposed solutions would, AFAICT, allow one to write "x + $x" to end up with a value of 2*x. That
is something I have not seen elsewhere and may end up doing more harm
than good.
I'm not sure it is a good idea to include single character function names in the base TCL set.
Things like:
proc a {...
are too useful at the command line.
For example I have my own take on a expr I call uexpr (it does math with units like ft sec kg watt ... etc).
package require uexpr
exposes the uexpr command at the global level.
There is an option in the uexpr pkgIndex.tcl for:
package require uexpr=
that aliases = to uexpr for convienence at the command line (= 3ft+6in=cm returns "106.68 cm")
However when I write a package "calc" to format calculations to generade .pdf files using pdflatex
and uexpr, I require uexpr, and use the canonical uexpr name in the package code
because the = alias might be preempted for some other purpose at the command line.
I think single character command names are too useful at the command line to be "taken" by the base TCL language or a widely used package.
daveb
Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk> posted:
I'm now thinking about those places like lindex where an argument is
end-2 and stuff like that.
That's a DSL that could do with being generalised.
In the Discussion section of TIP 676 I said:
Some of the string and list-related commands already support a restricted
form of numeric expressions for indices, e.g. [lindex $list end-2]. This
could be generalised in future by having them temporarily define end as
the appropriate value and run the = processing on index arguments.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 11:57:36 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
5 files (10,064K bytes) |
| Messages: | 265,373 |