shithub: martian9

ref: bdb99b496ec68880effa7df50fb4b05e7c1799bc
dir: /notes.org/

View raw version
* Current work
Need to take advantage of ellipsis() to handle generating extras
* 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
** TODO make a "macro_reader" like a "list_reader"?
* 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 ()
  ((_) #t)
  ((_ test) test)
  ((_ test1 test2 ...)
    (if test1 (_ test2 ...) #f))))