Here's a new-to-me trick:
I often use key=value pairs.
Sometimes I use name: value.
I.e. both = and : are nice ways of binding name and value.
How about:
n1: nA=vA, nB=vB, nC=vCor whatever way you want to express name/value in XML.
=>nA=vA, nB=vB, nC=vC
=>
I.e. : as a binding operator that can bind to a list of name=value pairs
Or non-XML, if that's what tickles your fancy. JSON?:
{ "n1": {"nA": "vA", "nB": "vB", "nC": "vC" } }(BTW, if I ever declare that I am doing pseudo-JSON, it will be to have fewer quotes.)
{ n1: {nA: vA, nB: vB, nC: vC } }
The biggest difference between shell script languages and regular languages is quoting. "Barewords" are a big characteristic of scripting languages.
:s can bind until the next colon - i.e, all colons have the same strength
n1: nA=vA, nB=vB, n2: v2, n3: nX=vX, nY=vY
{ n1: { nA:vA, nB:vB}, n2:v2, n3: {nX:vX, nY: vY} }To get more levels deep, would need brackets, or indentation. more operators: ::==
Heck, I'm not trying to define a full language here. There are at least 3 perfectly good data languages - XML, JSON, S-expressions.
I just want to define some notation that is a bit more user friendly, but can fall back to the other notations if necessary.
4 comments:
Might I recommend "Tcl Object Notation"?
http://mudge-a209.blogspot.com/2011/05/tcl-object-notation.html
Thanks, Ed. Yet another...
Anyway, I'll keep stealing ideas for my pseudo-object-notation (oo, I like that, PSON (Pseudo Object Notation).
It looks like the TCL object notatiin is one key value pair per line. I don't necessarily like that. Or ios it parity based, alternating key value?
While we are at it, in Perl SQL I used plain old Perl:
{ key => value, key => [ array, value ], ...}
etc.
I admit that I just plain evaled it the first time around (although I did use Safe::eval
It is parity based, any whitespace works. You can include whitespace (in a key or value) using "my key" or {my key}. Curlies nest, while " runs to the next "
Post a Comment