# s-expressions s-expressions are the good idea hiding in Lisp. Use them in place of JSON or Protobuf for program-to-program communication. Advantages: - Very simple and easy to parse - Plaintext - Compresses well s-expressions are relatively easy for a human to read and write, but you should be *inspecting* it more often than writing it by hand. A <300 line C implementation is provided further down. It's used like so: ```c char *dept = "finance"; int salary = 90000; char *name = "Jane Doe"; ha_sexp_printf("(ads)", dept, salary, name); // prints (finance 90000 "Jane Doe") ``` To scan this back in: ```c char dept[16]; int salary; char *name = NULL; int n = ha_sexp_scanf("(ads)", &dept, sizeof(dept), &salary, &name); if (n != 5) { // Input does not match spec } // ... free(value); ``` Grammar (McKeeman form): sexpr value '(' sexpr ')' value atom string integer float atom alnum atom alnum string '""' '"' characters '"' characters character character characters character '0020' . '10FFFF' - '"' - '\' "\u" hex hex hex hex '\' '\' '\' '"' digit '0' . '9' digits digit digit digits integer digits float digits '.' digits alnum digit 'a' . 'z' '_' '-' hex 'a' . 'f' digit Put that on your business card, Crockford.