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

Collapse
Posted by Benjamin Brink on
Hello Tony Kirkham,

Package developers usually implement changes within a separate package.

This usually precludes modifying an existing proc. Changing behavior on an existing proc may adversely affect another that, for instance in this case, expects an error.

If the changes are applicable to the core, core developers tend to find it and incorporate it directly, or by copying the functionality of the code while improving on it.

FWIW, there are a few practical variations of the Tcl dict paradigm in Q-forms package, mainly regarding looping and converting a batch of name values from/to array, lists, and scalars. Special cases allow limiting the names, or assigning an empty string if a value is not found for named index etc.

cheers,
Ben

Collapse
Posted by Tony Kirkham on
Thanks for the comments and feedback.

This change is not changing existing behavior. It is adding behavior in the form of a new sub command which amounts to a more succinct way to express something than what currently exists.

So instead of writing things like (which is suggested above)
set a [expr {[dict exists dict_val key] ? [dict get dict_val key] : ""}]
-or-
if { [dict exists dict_val key] && [dict get dict_val key] ne "" } ...

we could write
set a [dict getnull dict_val key]
-or-
if { [dict getnull dict_val key] ne "" } ...

I am considering adding it to my systems and wondered if the community would find value in it and where it made the most sense to place something like this.

-Tony