Hacker News new | past | comments | ask | show | jobs | submit login

> Macros aren’t marked, so any unknown term might be a macro.

Yes, that's a problem.

There are two clues:

* Macros typically have naming conventions. For example anything beginning with DEF should be a defining macro, not a function. Anything with DO- will be a control structure. Anything with WITH- will be a scoping macro. And so on. Avoid active names like CREATE- and use DEFINE- instead. CREATE-CLASS would be a function, DEFINE-CLASS would be a macro.

* In source code the enclosed code typically has syntax and special indentation, when used with macros. Functions have certain uniform indentation rules.

    (create-class 'container-ship
                  :superclasses '(ship)
                  :slots '((max-number-of-containers :type integer))
                  :documentation "our new container-ship class")
Above is a function and uses one of the typical formatting/indentation rules for functions. Line up the arguments. Start with the required argument and then the named argument pairs (name, arg).

The macro looks different. The first important things like name and superclasses are on the first line. The other parts of the class specification follow and are indented by two characters.

    (define-class container-ship (ship)
      ((max-number-of-containers :type integer))
      (:documentation "our new container-ship class"))
Developers who write macros should make it clear what a macro is, by using hints like these.



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

Search: