mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Issue #480 - Make (expand) easier to use
Only require a single expression argument. The remaining environment arguments are generally not required when debugging from the REPL. This makes expand much easier to use for casual debugging.
This commit is contained in:
parent
607ece0fce
commit
f8717517a4
2 changed files with 15 additions and 4 deletions
|
@ -34,6 +34,11 @@ A non-standard function to initialize a new global environment.
|
|||
|
||||
# expand
|
||||
|
||||
(expand expr environment rename-environment)
|
||||
(expand expr [[environment] [rename-environment]])
|
||||
|
||||
Perform macro expansion on `expr` and return the resulting expression.
|
||||
|
||||
`environment` may be optionally passed as the current environment.
|
||||
|
||||
`rename-environment` is an optional argument of an environment containing variables renamed directly by macros. This would generally be an empty environment when using this function for macro debugging.
|
||||
|
||||
Perform macro expansion on `expr` and `environment` is the current environment. `rename-environment` is an environment containing variables renamed directly by macros; this would generally be an empty environment when using this function for macro debugging.
|
||||
|
|
|
@ -982,8 +982,14 @@
|
|||
;TODO: modify this whole section to use macros:get-env instead of *defined-macros*. macro:get-env becomes the mac-env. any new scopes need to extend that env, and an env parameter needs to be added to (expand). any macros defined with define-syntax use that env as their mac-env (how to store that)?
|
||||
; expand : exp -> exp
|
||||
|
||||
(define (expand exp env rename-env)
|
||||
(_expand exp env rename-env '() '()))
|
||||
(define (expand exp . opts)
|
||||
(let ((env (if (> (length opts) 0)
|
||||
(car opts)
|
||||
*global-environment*))
|
||||
(rename-env (if (> (length opts) 1)
|
||||
(cadr opts)
|
||||
(env:extend-environment '() '() '()))))
|
||||
(_expand exp env rename-env '() '())))
|
||||
|
||||
;; Internal implementation of expand
|
||||
;; exp - Expression to expand
|
||||
|
|
Loading…
Add table
Reference in a new issue