From: Andreas K. <and...@ac...> - 2011-05-12 22:09:20
|
ISO = In Search Of. I currently have a small local "dictutil" package which, then required extends the dict ensemble with two methods sort (self-explanatory) and get' (get + default if key is missing) I am now in search of other useful methods which could be added to this package. Then it can go into tcllib. -- Andreas Kupries Senior Tcl Developer ActiveState, The Dynamic Language Experts P: 778.786.1122 F: 778.786.1133 and...@ac... http://www.activestate.com Get insights on Open Source and Dynamic Languages at www.activestate.com/blog |
From: Brett S. <bre...@ya...> - 2011-05-13 00:51:34
|
Maybe some of the stuff here: http://wiki.tcl.tk/17686 Note, I really haven't tried those, just remember stumbling across that page... ----- Original Message ---- From: Andreas Kupries <and...@ac...> To: Tcllib Developers <tcl...@li...>; Donal K. Fellows <don...@ma...> Sent: Thu, May 12, 2011 3:08:14 PM Subject: [Tcllib-devel] ISO dict utility commands ISO = In Search Of. I currently have a small local "dictutil" package which, then required extends the dict ensemble with two methods sort (self-explanatory) and get' (get + default if key is missing) I am now in search of other useful methods which could be added to this package. Then it can go into tcllib. -- Andreas Kupries Senior Tcl Developer ActiveState, The Dynamic Language Experts P: 778.786.1122begin_of_the_skype_highlighting 778.786.1122 end_of_the_skype_highlighting F: 778.786.1133 and...@ac... http://www.activestate.com Get insights on Open Source and Dynamic Languages at www.activestate.com/blog ------------------------------------------------------------------------------ Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ Tcllib-devel mailing list Tcl...@li... https://lists.sourceforge.net/lists/listinfo/tcllib-devel |
From: Andreas K. <and...@ac...> - 2011-05-13 16:57:40
|
On 5/12/2011 5:51 PM, Brett Schwarz wrote: > Maybe some of the stuff here: http://wiki.tcl.tk/17686 > Note, I really haven't tried those, just remember stumbling across that page... Thanks. Looking at the page this is the origin of the WUB Dict.tcl mentioned by Tom. -- Andreas Kupries Senior Tcl Developer ActiveState, The Dynamic Language Experts P: 778.786.1122 F: 778.786.1133 and...@ac... http://www.activestate.com Get insights on Open Source and Dynamic Languages at www.activestate.com/blog |
From: Lars H. <Lar...@re...> - 2011-05-13 07:54:59
|
Andreas Kupries skrev 2011-05-13 00.08: > > ISO = In Search Of. > > I currently have a small local "dictutil" package which, then required extends > the dict ensemble with two methods > > sort (self-explanatory) > and get' (get + default if key is missing) Besides the command name (which is nice), does this have the same syntax as TIP#342 (http://www.tcl.tk/cgi-bin/tct/tip/342)? Lars Hellström |
From: Andreas K. <and...@ac...> - 2011-05-13 17:03:53
|
On 5/13/2011 12:54 AM, Lars Hellström wrote: > Andreas Kupries skrev 2011-05-13 00.08: > Besides the command name (which is nice), does this have the same syntax > as TIP#342 (http://www.tcl.tk/cgi-bin/tct/tip/342)? > > Lars Hellström Checking ... Yes. My implementation is pretty much the same as well, just an additional local variable to avoid doing the lrange twice, and explicit returns. # get value for key, with custom default if key not present. proc ::dictutil::get' {dict args} { set keys [lrange $args 0 end-1] if {[dict exists $dict {*}$keys]} { return [dict get $dict {*}$keys] } else { return [lindex $args end] } } The WUB Dict.tcl has a simimlar 'get?' method, except that it doesn't have a custom default, and always returns the empty string. Thanks to all the responses, keep them coming, in the ooutil thread too, I hope. For me, time to start digesting things ... -- Andreas Kupries Senior Tcl Developer ActiveState, The Dynamic Language Experts P: 778.786.1122 F: 778.786.1133 and...@ac... http://www.activestate.com Get insights on Open Source and Dynamic Languages at www.activestate.com/blog |
From: Neil M. <nei...@gm...> - 2011-05-15 22:07:13
|
On 12 May 2011, at 23:08, Andreas Kupries <and...@ac...> wrote: > > ISO = In Search Of. > > I currently have a small local "dictutil" package which, then required extends > the dict ensemble with two methods Others have mentioned the dictutils wiki page, so I have nothing extra to add there. I do have a minor niggle with extending a built-in ensemble though. IMO this should be a last resort if functionality can't be achieved in a separate (ensemble) command. This kind of "monkey patching" can lead to confusing and potentially brittle code as multiple extensions try to alter the same ensemble. I feel these maintainability considerations outweigh the neat syntax. Neil |