From: Brian Candler Date: 2010-09-22T20:20:23+09:00 Subject: Re: Ruby-based data language Thomas Sawyer wrote: > But if you look at Ruby-based configuration files > they always use block-based DSL notations, not hashes. I'd have said most packages use YAML. If you can provide examples which use method_missing and block-based structure just for conveying static configuration information, I'd be interested to see them. But then that's what you asked for in the first place :-) > So the analogy > isn't over the data structure, but rather the use of the underlying > language as a syntax model. The difference is that JSON *is* a direct subset of Javascript, and can be eval'd directly to give a value. Let me put it another way. If you were parsing your example: name "Joe Foo" age 33 contact do email "joe@joefoo.com" phione "555-555-1234" end would you expect as Hash oas the result? If yes: then it looks like you're proposing an alternative syntax for Hash literals - one which isn't widely used. It's Ruby-inspired but not really Ruby, since a simple eval of the above will fail without additional supporting code. It would be similar to Builder, but (a) creating a Hash as its output instead of XML, and (b) intended for use with untrusted inputs, so parsed rather than eval'd. If no: then what do you expect to get instead? I suppose you could have a stream parser API, and trigger start/end actions as you go, but that's not a very convenient API for reading a config file. -- Posted via http://www.ruby-forum.com/.