Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

belg4mit (967)

  (email not shown publicly)

Journal of belg4mit (967)

Saturday March 24, 2007
02:17 PM

Free commit bits for Data::JavaScript available

[ #32786 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • 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.
    • 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
      Were that I say, pancakes?
      • Well, uh... If only I understood what the purpose behind it all is. I don't.
        • 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.
          Were that I say, pancakes?
          • Is there any particular reason why you want to keep this alive, or is it largely obsolete?
            • 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.
              Were that I say, pancakes?