Forum OpenACS Q&A: Re: Additions to the tcl language

Posted by Antonio Pisano on
Hello Tony,

my personal two cents here: although I can see why one could need such a feature, I would not modify a standard tcl command for this. Chances are that this could get overridden or conflict in future tcl versions.

If this ever should make it to the openacs codebase, I would say it should go into a separate proc e.g. util::dict_get.

What is wrong with a oneliner like this? No procs involved and should do the trick

set value [expr {[dict exists dict noexist] ? [dict get dict noexist] : ""}]

Posted by Tony Kirkham on
That does work. It is just not as succinct.

I can understand the concern with future conflicts. To protect against that a check could wrap the creation of getnull so that, if it already exists, this code would not override it and a warning could be logged to leave tracks.