views:

357

answers:

3

Hello,

I am translating some lisp code to Tcl and wonder if there is anything like lisp's defstruct in Tcl for creating data structures?

If nothing is built into Tcl, what extension packages to Tcl would you recommend that can be used in a commercial application.

Thanks.

-William

+1  A: 

You could take a look at the pages on Rosetta Code under Data Structures. They all have Tcl examples.

Joey
Seems that associative array in Tcl is instance based and not type based. Do you know of any extensions to Tcl that provide this?
WilliamKF
No, sorry. I just happen to know that one of the Tcl Core Team members provides many Tcl solutions to tasks on RC. I don't speak any Tcl, unfortunately.
Joey
Tcl is not a typed language: "everything is a string" is a mantra. I'd go with `dict` for complex data structures, or use an OO package like Snit (http://wiki.tcl.tk/snit)
glenn jackman
+4  A: 

Consider using dictionaries, which work more or less like a hashmap. You can set the key/value pairs much like you would any other structure.

RHSeeger
A: 

Tcl tutor is having 44-47 lessons on dictionaries.

OliveOne