views:

137

answers:

3

Hi,

I need to use keyed lists with TCL, but have the option of only copying tcl code to the device.

The default method is to use TclX, but this requires compilation.

Is there any implementation of keyed list functions (keylset, keylget) which is available as a "standalone" library (i.e. pure tcl)?

+1  A: 

yes, in tcl 8.5, the dict command was added which implements a dictionary store, for example:

dict set d key1 val1
dict set d key2 val2

dict for {k v} $d {puts "$k = $v"}
jspcal
I am looking for something compatible with 8.3 . Sorry for not specifying this in the Question. Have found the solution.
Abhinav
If you have the time, it might be worth taking the pure Tcl keyed list implementation and re-implementing it using dicts instead raw lists. The reason being that the dict code is (I believe) optimized for the type of access you need and would likely be a lot faster.
RHSeeger
A: 

Found the solution at the end of this wiki page itself !

Abhinav
+1  A: 

If you take a look at this wiki page regarding keyed lists, where someone has written a pure tcl version of basic keyed list functionality. I didn't read in depth to see if they depended on dict or not. If so, there is a pure tcl implemention of dict elsewhere on the wiki.

lvirden
Yeah, I figured it out 15 minutes after posting here :) Anyway I needed a 8.3 compliant version, which it was not, unfortunately.
Abhinav