On Sep 21, 3:25 ¨Âí¬ ÂòéáÃáîäìå¼â®ãáîä®®®Àðïâïø®ãïí÷òïôåº > Thomas Sawyer wrote: > > name "Joe Foo" > > age 33 > > contact do > > email "j... / joefoo.com" > > phione "555-555-1234" > > end > > You could make a parser for that fairly easily - or transform it to JSON > or YAML and parse that (assuming that contact do .. end constructs a > nested Hash) > > > Such a format would be to Ruby as JSON is to Javascript. And Ruby has aice advantage with blocks. > > That's where I disagree with you. You are using blocks in a Builder or > Markaby way, but that's not the fundamental purpose or interpretation of > blocks in the language. And how would you handle Arrays? > > The Ruby equivalent of JSON would be a literal Hash: > > { > "name"=>"Joe Foo", > "age"=>33, > "contact"=>{ > "email"=>"j... / joefoo.com", > "phone"=>"555-555-1234", > }, > > } > > Or if you buy into 1.9 syntax, then you could have > > { > name: "Joe Foo", > age: 33, > contact: { > email: "j... / joefoo.com", > phone: "555-555-1234", > }, > > } > > Both are similar enough to JSON that I'd use that instead, and gain the > portability benefit. It's a shame that JSON doesn't allow trailing > commas. That's a good point. But if you look at Ruby-based configuration files they always use block-based DSL notations, not hashes. So the analogy isn't over the data structure, but rather the use of the underlying language as a syntax model.