Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I made a nice Lisp with a comprehensive macro system.

I also use it to handle my contracting finances. Let's grep that software for "macro":

  $ grep 'macro' *.tl
  money.tl:(defmacro define-relational (name binary)
  money.tl:(defmacro define-arith-predicate (name usr-package-fun)
  money.tl:(defmacro define-unary (name usr-package-fun)
  time.tl:(defmacro def-date-var (name fallback-val . date- range-val-triplets)
  time.tl:         (defsymacro ,name (range-lookup *date* ,fb ,rvt))))
Five hits; that's it! Three macros in money; they are all local shorthands just to eliminate some repetitive code. One macro in time for defining a date-specific variable, and that macro introduces a global symbol macro when invoked.

The bulk of the system is OOP code: accounts, transactions, expenses, invoices, deltas, ... things with boring stuff like slots and methods. (Of course, I wrote that object system with a fair bit of contribution from macros; but that's in the language, not in the project).

The DSL for recording transactions consists of plain old functions with transparent contents: just instantiate certain objects, do certain calculations and insert into the ledger.

The date-specific variable thing is cool; it lets us define a variable, such as an income tax deduction rate, which has different values based on what date it is. Not the current system date, but the context date for the creation of a transaction: the date to which it is being accrued. A macro helps define that with a clear syntax, and the symbol macro makes it look like an ordinary variable.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: