Karl Lehenbauer wrote:
How about if "get" still returns an empty string when the key doesn't exist but I implement "exists" for people who want to clearly distinguish between missing and empty?

it might work out a compromise.

I also considered adding an optional argument to "get" of a variable name to load with the value and having it return 1 or 0 on whether or not the key exists...

  if {[apache_table get notes key valueVar]} {
  }

...but it seems like overkill.


what if 'apache_table get notes key' returns an error if 'key' is not existing or returns $valueVar if the last argument is present?

if {[catch {apache_table get notes key} errcode]} { ... }

if {[apache_table get notes key ""] == ""} { ... }

this would enable us to use also defaults that are numbers...
-karl

PS - As an aside, Tcl arrays should have a settable default, "array default arrayName 0" would be cool, although newer incr will instantiate a nonexistent variable at 0. Also there should be something like "array foreach arrayName var code".


yes definitely. Will you bring up a proposal for this on Tclcore?


-- Massimo

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscr...@tcl.apache.org
For additional commands, e-mail: rivet-dev-h...@tcl.apache.org

Reply via email to