AOLserver already includes keyldel, keylget, keylkeys, and keylset, but they aren't a suitable ns_set replacement. I'll finish documenting these on the Wiki if someone doesn't beat me to it ;-)
Back in April 2001, people posted lists of their most frequently used AOLserver commands, and ns_set was near the top of most lists. Even if there are alternatives that make sense for future development, I think it would be reasonable to enhance ns_set if the functionality is useful. It might be interesting to see how command usage has changed in the past three years. I suspect not much has changed, ns_share -> nsv is the only thing that really comes to mind. As an example of how ns_set keys and values might be handy, in some of my code I often need to generate a <SELECT> using ns_htmlselect from the keys and values in an ns_set, which means we need separate lists of the values and labels to pass to that proc. So we implemented ns_set keys and values functionality at the TCL level for this and other uses. (As an aside, ns_htmlselect also needs cleanup to be useful.) I went ahead and patched AOLserver locally, < 20 lines of code, taken directly from ns_set array. In tclsh: % load nsd % set setId [ns_set create] d0 % for {set i 0} {$i < 1000} {incr i} { ns_set put $setId k$i v$i } % time {ns_set keys $setId} 10000 147 microseconds per iteration % time { set l [list] foreach {key value} [ns_set array $setId] { lappend l $key } } 10000 3341 microseconds per iteration % time { set l [list] set s [ns_set size $setId] for {set i 0} {$i < $s} {incr i} { lappend l [ns_set key $setId $i] } } 10000 3803 microseconds per iteration A 1000-field ns_set isn't typical of course, the C version is maybe 10x faster than the TCL work-alikes for ns_sets with 10 fields. Jamie On Fri, 11 Jun 2004 10:43:41 -0700, Brett Schwarz <[EMAIL PROTECTED]> wrote: >--- Brett Schwarz <[EMAIL PROTECTED]> wrote: >> > >> > Rather than building on top of Tcl Array, another >> > alternative is to >> > use some entirely new from-scratch C >> implementation, >> > in the future >> > maybe even something like Ratcl. But I'm not >> aware >> > of any existing >> > code that would currently be a good fit as an >> ns_set >> > replacement. >> > >> >> >> I've never really used them but what about keyed >> lists >> in Tclx? I believe the order is preserved, and by >> the >> looks of it, it has a very similiar interface to >> ns_set (from a quick look through). It also supports >> nesting, which would be nice. Maybe we could hijack >> this???? >> > >although it doesn't support duplicate keys :( > > > > > >__________________________________ >Do you Yahoo!? >Friends. Fun. Try the all-new Yahoo! Messenger. >http://messenger.yahoo.com/ > > >-- >AOLserver - http://www.aolserver.com/ > >To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the >body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank. -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.