Tk Library Source Code

View Ticket
Login
Ticket UUID: 1970893
Title: Serialize Helper
Type: RFE Version: None
Submitter: kanryu6 Created on: 2008-05-23 22:18:37
Subsystem: tcllib: request for new module Assigned To: nobody
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2008-06-06 20:17:31
Resolution: Closed By: kanryu6
    Closed on: 2008-06-06 13:17:31
Description:
This library holds the data of complicated structure more strictly, and offers the means to write out.
In Tcl, the internal expression of "space separated string"s, "list"s, and "dictionary(dict)"s are the same, and is not mutually distinguished so that it may know.
It is simplicity peculiar to Tcl.
However, there is a fault that it is undistinguishable what the node is in the library side to write out the data of the two or more floor layer to XML, JSON, YAML, etc. as a fault.
Then, it stores once what each node is in the "tree" specified clearly, and was made to change into the target form from there.
It seems that it is moving well although the code which changes the data of five classes into a trial at JSON form was described.
But I feel [ that are a wonderful talk and I have not found the library and its usage ] only for such a fundamental thing not being offered as a library.
This library is whether to be required and ? (should be recorded on tcllib?).
And, what kind of library name should it be?

# -----------------
# working sample
% set bb [huddle create a b c d] ; # create as a dict
HUDDLE {d {a b c d}}
% set cc [huddle create e f g h]
HUDDLE {d {e f g h}}
% set bbcc [huddle create bb $bb cc $cc]
HUDDLE {D {bb {d {a b c d}} cc {d {e f g h}}}}
% set folding [huddle list $bbcc p [huddle list q r] s] ; # create as a list
HUDDLE {L {{D {bb {d {a b c d}} cc {d {e f g h}}}} {s p} {l {q r}} {s s}}}
% huddle strip $folding ; # normal Tcl's notation
{bb {a b c d} cc {e f g h}} p {q r} s
% huddle jsondump $folding ; # dump as a JSON stream
[
  {
    "bb": {
      "a": "b",
      "c": "d"
    },
    "cc": {
      "e": "f",
      "g": "h"
    }
  },
  "p",
  [
    "q",
    "r"
  ],
  "s"
]
User Comments: kanryu6 added on 2008-06-06 20:17:31:
Logged In: YES 
user_id=2072360
Originator: YES

It uses in the yaml library now.
It is in the same directory.

kanryu6 added on 2008-05-31 20:34:29:

File Added - 279694: huddle-0.1.2.tar.gz

Logged In: YES 
user_id=2072360
Originator: YES

- add command "huddle combine"
- add command "huddle equal"
- add command "huddle append"
- support inheritance for type-callbacks.

I want to append the library to Tcllib.
I already have replaced codes in the yaml-lib.(but not committed)

Although I am going to put on the same directory as yaml-lib, may I commit for a while?
File Added: huddle-0.1.2.tar.gz

kanryu6 added on 2008-05-26 06:49:02:

File Added - 279039: huddle-0.1.1.tar.gz

Logged In: YES 
user_id=2072360
Originator: YES

supported for adding user-type/tag.
removed simple container tags ("l", "d")
add command "huddle set"
add command "huddle remove"

File Added: huddle-0.1.1.tar.gz

kanryu6 added on 2008-05-24 07:26:16:
Logged In: YES 
user_id=2072360
Originator: YES

Thank you for the kind description.
That's right.

Huddle provides a generic Tcl-based serialization/intermediary format.
Currently, each node is wrapped in a tag with simple type information.

huddle-format: >
  {HUDDLE {tag {huddle-node}}
huddle-node: >
  {tag {huddle-node(content)}}
each tag means:
  s: (content is a) string
  l: Tcl's list, each node is a string
  d: Tcl's dict, each node is a string
  L: list, each node is a huddle-node
  D: dict, each node is a huddle-node
confirmed:
  - JSON
  - YAML(generally, but cannot discribe YAML-tags)
limitation:
  - cannot discribe the aliase from a node to other node.


I want to use the format/library for serializing to YAML/JSON streams.

andreas_kupries added on 2008-05-24 05:46:33:
Logged In: YES 
user_id=75003
Originator: NO

It took me while to understand the description.
Well, I believe that I understand it now.
So let me try to describe it in my own words.

(1) Huddle provides a generic Tcl-based serialization format
(2) The entries in that format are tagged with simple type information
(3) The currently the known types are 'L' for list, and 'D' for dict.
(3a) There are also 'l' and 'd', these I do not understand yet.
(4) When converting huddle-notation to other serialization formats like
    JSON or YAML this type information is used to select the proper notation.
(5) And when going from JSON/YAML/... to huddle their notation can be used to
    select the proper huddle type.
(6) In that manner huddle can serve as a common intermediary format.
(7) The nice thing about its notation that Tcl can read this format directly
    (list/dict commands) without the need for a special parser.

Side note: Origin seems to be http://wiki.tcl.tk/21116

kanryu6 added on 2008-05-24 05:20:34:
Logged In: YES 
user_id=2072360
Originator: YES

Sample code again:

# -----------------
# working sample
% set bb [huddle create a b c d] ; # create as a dict
HUDDLE {d {a b c d}}
% set cc [huddle create e f g h]
HUDDLE {d {e f g h}}
% set bbcc [huddle create bb $bb cc $cc]
HUDDLE {D {bb {d {a b c d}} cc {d {e f g h}}}}
% set folding [huddle list $bbcc p [huddle list q r] s] ; # create as a list
HUDDLE {L {{D {bb {d {a b c d}} cc {d {e f g h}}}} {s p} {l {q r}} {s s}}}
% huddle strip $folding ; # normal Tcl's notation
{bb {a b c d} cc {e f g h}} p {q r} s
% huddle jsondump $folding ; # dump as a JSON stream
[
  {
    "bb": {
      "a": "b",
      "c": "d"
    },
    "cc": {
      "e": "f",
      "g": "h"
    }
  },
  "p",
  [
    "q",
    "r"
  ],
  "s"
]

kanryu6 added on 2008-05-24 05:18:38:

File Added - 278840: huddle-0.1.0.tar.gz

Attachments: