shithub: martian9

ref: cee3c78840d9cde8172fb8f167a75f20ecf6451c
dir: martian9/notes.org

View raw version
* First things:
** DONE Remove kw_macro
We determine what's a macro based on "syntax-rules" (so we need to make sure that's always there)
** DONE (let) doesn't work at all
** Should (let) include an implicit (begin)?
s9fes seems to do it
** TODO need an "unspecified" type?
** TODO (display) should return unspecified
** TODO implement (pair)
Pairs should be preserved, I think
Also, it should _only_ be pairs, nothing more.
** PROGRESSING (define) needs to support function definitions
Right now you need to use lambda
** DONE (cons) doesn't work
This appears to work, now, but not with a pair
* Read
** macro "transformers" should be "clauses"
Which themselves consist of "pattern" -> "template"
** DONE "quote" and "quasiquote" symbols not supported
The shortcuts work, but not the keywords
** TODO switch "define-syntax" to "let-syntax" format
I think 'let-syntax' is the better building block
* Eval
* Print
* Things to watch for
** fold-case directives (2.1)
They affect the port for all remaining activity on that port.
** bar identifiers (2.2)
How do they work? |some id|?
** yet another comment? (2.2)
How to handle #;
* Macro expansion
** Workflow
- Take pattern
- substitute args for non-literals (in order)
- compare result with ast - if it's a match, return a lamba with the matching args and the transformer
...but what about ellipsis??
** Thoughts
Eval seems too late to handle it, so maybe try to do expansion at read?

So, at read, do an expansion and store the macro variants with unique names
Then, when the original macro is called again, match the pattern and sub-in the appropriate variant.
* Macros
** and
(define-syntax and (syntax-rules ()
  ((and) #t)
  ((and test) test) ((and test1 test2 ...)
    (if test1 (and test2 ...) #f))))