On 4/14/06, Clark C. Evans <cce@clarkevans.com> wrote:

[...] (i.e., snip)

Ordered Pair Notation
---------------------

About the same time as Set Notation emerged, we also had people who
wanted to serialize ordered pairs.  The syntax of using a list of lists,
or a list of mappings, and indenting or using brackets was considered
"too tedious" by many users at the time (especially a few PhP advocates).
Hence, having the TMTOWTDI philosophy borrowed from Perl, we came up
with stuff like:

  ---
  - first: pair
  - second: pair
  - third: pair

And, the corresponding flow style,

  [ first: pair, second: pair, third: pair ]

To this day, I'm not exactly sure if this was such a great addition,
however, it is a bit late to change.  The result of both of these
structures, from a YAML data model perspective, is a list of mapping
objects where each mapping has exactly one key/value. What I do agree
about is that both set and ordered-pair notation are, er, quite clever.

I know of one use case which might provide an argument
why this is a good addition.  I'm exploring how to use YAML
to work out an age-old issue: helping humans edit MARC
records. It seems to me that ordered pair notation matches
the MARC structure exactly, e.g. (excerpted):

- leader: 02507cas a2200481 a 4500
- 001: 2096746
- 005: 20030611092952.0
- 006: 'm        d f      '
- 007: cj uou
- 008: 920228d19891991dcuar   ss   f0    0eng d
- 010:
    - -1: ' '
    - -2: ' '
    - a: sn 92019106
- 035:
    - -1: ' '
    - -2: ' '
    - a: ocm25361431
- 040:
    - -1: ' '
    - -2: ' '
    - a: COO
    - c: NST
- 245:
    - -1: 0
    - -2: 0
    - a: 'U.S. crude oil, natural gas, and natural gas liquids reserves'
    - h: '[electronic resource] /'
    - c: U.S. Department of Energy.
- 362:
    - -1: 0
    - -2: ' '
    - a: 1977/1989-
- 300:
    - -1: ' '
    - -2: ' '
    - a: computer disks ;
    - c: 5 1/4 in. +
    - e: users guide
- 310:
    - -1: ' '
    - -2: ' '
    - a: Annual
- 856:
    - -1: 4
    - -2: 1
    - u: http://purl.access.gpo.gov/GPO/LPS29897
- 949:
    - -1: ' '
    - -2: ' '
    - h: 'J84:'
    - i: 'E 3.34:'

MARC records have (usually numerically tagged) fields
and (usually 1-character-tagged) subfields, plus the odd
"indicators", which I've noted above as -1, -2.  While at
first glance, you might think the fields are ordered by their
tags, they're not (e.g., 245, 362, 300).  The same is true for
subfields (e.g., 245 $a, $h, $c).  Therefore, a MARC record
is very faithfully representable as two tiers of ordered pairs.

Arguably, I don't need -1, -2, i.e.,

- 856:
    - 4
    - 1
    - u: http://purl.access.gpo.gov/GPO/LPS29897

I'm still ruminating about that.  But I digress.

[...]

Allow, but Complain if not obvious
----------------------------------

[...]

Of the three choices, this sounds most reasonable to me.
I don't know the efficiency (i.e., speed) implications, but I
suspect that they either will be acceptable, or that problems
will be solved.

Regards,

Brad