31 August 2010

Why EMSIP?

Why EMSIP is a good thing

EMSIP is my idea of how s-expressions could be extended without losing their well-behavedness.

Common Lisp reader macros read arbitrary stretches of text. They only need stop when the macro decides it has read enough. It need not respect bracketing. But without reliable bracketing, s-expressions become a lot less predictable, and therefore a lot harder for tools to handle. So Common Lisp reader macros destroy the well-behavedness of s-expressions.

There are several ways you can think about a solution:

  • Just don't expect tools to handle arbitrary reader macros. So now your tools can't fully read your code. Bad idea.
  • Don't use any extensions? Impractical.
  • Put all of the intelligence that your reader macros have into every one of your tools. There's no portable or reliable way of doing this.
  • Use a different system of s-expressions. But Scheme macros have the same problem.

EMSIP offers a solution. EMSIP always respects bracketing. A bracket always means a nesting operation, except for one special case. And even that case is very mild: In special scopes, there is an attention string and only brackets immediately preceded by that attention string "count".

Further (minor) deficiencies of s-expressions

EMSIP offers even more regularity. Although normal, non-reader-macro'd s-expressions are fairly well behaved, they have lots of exceptional cases. For instance:

  • The lowly string literal, eg "abc". It doesn't have start and end brackets, it has one unibracket that both starts and ends it.
  • Quoting and backquoting. They aren't standalone s-expressions, they want to alter the meaning of the s-expression that follows them.
  • Exceptional symbols such as `&optional' in formals lists. They don't want to be symbols in a list. Like quoting, they want to alter the meaning of what follows them.

EMSIP will make all of that more regular.

No comments:

Post a Comment