Compared to non-lisp languages, the regularity of s-expressions and being able to treat code as data and the other way round (homoiconicity) is a big advantage.
thanks to pinoaffe for this point.
This is an essential elegance I want to conserve in wisp.
Wikipedia notes as advantage that
extending the language with new concepts typically becomes simpler, as data representing code can be passed between the meta and base layer of the program. — Homoiconicity: Uses and Advantages
and
It can be much easier to understand how to manipulate the code since it can be more easily understood as simple data (since the format of the language itself is a data format). — Homoiconicity: Uses and Advantages
For Wisp I use this a lot, because it allows me to do a first simple pass over the code, add incremental improvements and finally have the cleaned up code that I can pass to the language spec definition:
define : wisp-scheme-read-chunk port . "Read and parse one chunk of wisp-code" let : : lines : wisp-scheme-read-chunk-lines port wisp-make-improper wisp-replace-empty-eof wisp-unescape-underscore-and-colon wisp-replace-paren-quotation-repr wisp-propagate-source-properties wisp-scheme-indentation-to-parens lines
Also this enables me to write a Question-Asking macro for dryads wake without going totally insane. Usage:
Choose : new game ,(first-encounter) : load game ,(load-game) : show prologue ,(prologue) ,(welcome-screen) : exit We hope you enjoyed our game!
Definition:
define-syntax-rule : Choose . choices . "Ask questions, apply consequences" begin say-lines : ("") ;; newline before question let loop : ;; Get the response via the Ask macro ;; to evaluate inline-code incrementally define resp : string->number : Ask choices or cond : equal? resp 1 Respond1 choices : equal? resp 2 Respond2 choices : equal? resp 3 Respond3 choices : equal? resp 4 Respond4 choices : equal? resp 5 Respond5 choices : equal? resp 6 Respond6 choices else . #f loop define-syntax Ask lambda (x) syntax-case x () : _ (choices ...) #` begin ask (QuoteFirsts (choices ...))
QuoteFirsts interprets the questions as data but leaves the answers as
code which can e.g. use ,(load-game) to open the load game dialog.