Monday, January 2, 2012

New Year's Resolution: More Blogging

I hope to get back to this blog soon, in fact, it's one of my New Year's resolutions!

In the meantime, here's a thought.

It's really easy to write external DSLs using s-expression languages. A decent parser can be hand written in a few hours, and the eval process is well understood and documented. (See for example Design Concepts in Programming Languages by Turbak, et al., or "Abelson and Sussman" on the sidebar of this blog.)

But all those parentheses!

Well, if your language works line-by-line, and every line is a cons, you can easily strip away at least one layer of parentheses by simply assuming the entire line is a cons (unless an outer parenthesis really is found).

For example, here's how it would look in a pretend language:

(new: client bob)
  (set: phone 555-5555)
  (set: acct-balance 1000)
new: client bob
  set: phone 555-5555
  set: acct-balance 1000

Now isn't that better?

Happy New Year, Neil

No comments: