Stories
Slash Boxes
Comments
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 ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Friday February 15, 2008
05:05 AM

Revised Bermuda Islands

[ #35662 ]

Since hdp and schwern both recommended that I specify elements in Bermuda Island files as a list of key/value pairs, I've gone ahead and tried it out. It much easier to read now. I have this:

---
package: Some::Class
island: dummy
attributes:
  name:
    type: string
  version?:
    type: integer
  some_val?:
    type: integer
    if: $instance->some_val > 1
elements:
  - personal_email:
      type: string
      method: email('personal')
  - work_email:
      type: string
      method: email('work')

Turning into this:

{
   "elements" : [
      {
         "value" : "victoria@example.com",
         "name" : "personal_email"
      },
      {
         "value" : "victoria@some_company.com",
         "name" : "work_email"
      }
   ],
   "name" : "dummy",
   "attributes" : {
      "version" : 3,
      "name" : "Victoria",
      "some_val" : 4
   }
}

Obviously that's just the built-in JSON serialization.

Unless I get radically more free time soon, I likely won't be able to do much more for a couple of weeks.

I also note that if I make attributes an ordered list of k/v pairs, then the attribute and element syntax becomes identical, with the exception that attributes are not allowed to have '*' or '+' quantifiers. This would be very, very handy. However, attributes in XML are, by definition, not ordered, so imposing an order sounds wrong. On the other hand, imposing an order, even as a convenient side-effect, shouldn't hurt consumers of the serialized data structures and might help poorly coded consumers. Also, simply making it easier to write Island files by normalizing the syntax is very appealing.

Update: Yuck. I need to clean up my JSON and YAML even more. That should read:

{
   "elements" : [
      "personal_email" : "victoria@example.com",
      "work_email" : "victoria@some_company.com"
   ],
   "name" : "dummy",
   "attributes" : {
      "version" : 3,
      "name" : "Victoria",
      "some_val" : 4
   }
}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.