-
Notifications
You must be signed in to change notification settings - Fork 13
Coding Conventions
Siddhartha Kasivajhula edited this page Jan 27, 2024
·
1 revision
We're pretty lax about coding conventions for now. Here are some basic guidelines:
- Use box brackets for nested clauses in forms like
cond
- Use indent configuration consistent with the codebase and DrRacket conventions
Here is some indentation config for use in Emacs's Racket Mode. It would be ideal to incorporate this into development workflows in a convenient automated way (e.g. setting it up as dir local config which could be included in the project repository).
These go in the :config
section of your use-package
declaration for Racket Mode:
;; indent levels for built-in forms
;; TODO: probably contribute upstream to racket-mode
(put 'datum->syntax 'racket-indent-function 1)
(put 'pattern 'racket-indent-function 1)
;; indent levels for syntax-spec
(put 'syntax-spec 'racket-indent-function 0)
(put 'nonterminal 'racket-indent-function 1)
(put 'nonterminal/nesting 'racket-indent-function 2)
(put 'nonterminal/two-pass 'racket-indent-function 1)
(put 'host-interface/expression 'racket-indent-function 0)
(put 'host-interface/definition 'racket-indent-function 1)
(put 'host-interface/definitions 'racket-indent-function 1)
;; indent levels for cli forms
(put 'program 'racket-indent-function 'defun)
(put 'flag 'racket-indent-function 1)
;; indent levels for qi forms
(put 'switch 'racket-indent-function 'defun)
(put 'switch-lambda 'racket-indent-function 1)
(put 'on 'racket-indent-function 1)
(put 'π 'racket-indent-function 1)
(put 'try 'racket-indent-function 1)
;; one-offs / project-specific
(put 'report-syntax-error 'racket-indent-function 1)
Home | Developer's Guide | Calendar | Events | Projects | Meeting Notes