Free commit bits for Data::JavaScript available

belg4mit on 2007-03-24T19:17:41

I've been really bad about maintaining Data::JavaScript, so if anybody is interested in getting contributor maintenance rights for CPAN let me know, preferably with a respectable sample patch*.

Here are some of the things on the TO DO list:

  • Merge ::LiteObject and ::Anon functionality into D::JS
  • Code cleanup, including removal of Exporter; this naturally follows from the former.
  • Explore Data::Dumper and it's $Pair or similar to sit atop one of these engines?
  • Likewise JSON? (Update: and therefore obviously therefore array literal syntax)
  • A reasonable means of defining hash sort order
  • Consider a less verbose format (option) for generic output, such as that proposed by Scott Wessels
    #AB's code output
    var facts = new Object;
    facts.string = 'Joseph';
    facts.xor = new Array;
    facts.xor[0] = new Array;
    facts.xor[0][0] = 0;
    facts.xor[0][1] = 1;
    facts.xor[1] = new Array;
    facts.xor[1][0] = 1;
    facts.xor[1][1] = 0;


    #vs. SW output
    var facts = new Array(new function() {
    this.string = 'Joseph';
    this.xor = new Array(new Array(0,1),new Array(1,0));

    }

    I have an old patch for this, it sort of preserves references.
  • A sane way to handle all of that. Probably a single engine with multiple wrappers for different output options?
  • Fix documentation i.e; clearer description of what data munging is done (minimal by default, if you want to embed JS within JS strings, more need to be done [somewhere])

*The patch could be for (part of) something on the TO DO list, or anything else appropriate.


new Array/new Object

bart on 2007-03-24T22:19:08

Why are you using new Array/new Object? That is oh so verbose, and has no benefit over the the much shorter (and Perl compatible) [] resp. {}. On the contrary:

new Array(3)
will produce an array of 3 null items, while

new Array(3, 4)
will produce an array of 2 items: the values 3 and 4.

Re:new Array/new Object

belg4mit on 2007-03-24T22:26:05

Because

a) This is very old code, and we try to support older JavaScript versions (though there is no reason why, when you you tell the module you want v1.4 that it shouldn't use the slimmer syntax)

b) I'm not the original author. I wrote LiteObject and said I'd maintain this when Ariel passed away.

c) See the points already made in the original post (less verbose format, JSON-like format)

So the real question is, if it offends you so, are you going to submit a patch to gain commit rights? :-P

Re:new Array/new Object

bart on 2007-03-24T23:07:32

Well, uh... If only I understood what the purpose behind it all is. I don't.

Re:new Array/new Object

belg4mit on 2007-03-24T23:17:58

Data dumping to JavaScript. Be it for use with AJAX, or any other client-side data exporting purposes. It predates JSON and affords more flexibility. For instance, LiteObject is pretty efficient (nearly as small as literals but pre-JS1.2 compatible) and a good idiom for certain kinds of data.

Re:new Array/new Object

bart on 2007-04-01T11:10:29

Is there any particular reason why you want to keep this alive, or is it largely obsolete?

Re:new Array/new Object

belg4mit on 2007-04-01T15:12:56

I'm sorry, this is a non-sensical question: the second part does not follow from the first, and I've already made the case for maintaining it.