diff --git a/docs/docs/lips/environments.md b/docs/docs/lips/environments.md index 17393544..bfa5bd38 100644 --- a/docs/docs/lips/environments.md +++ b/docs/docs/lips/environments.md @@ -42,9 +42,41 @@ In LIPS you can change the environment with `let-env` syntax: ;; ==> 30 ``` +## Scheme Report Environments +Scheme standard provide environments for given version of the [RnRS +specification](/docs/scheme-intro/what-is-lisp#standards) in a form of a function +`scheme-report-environment`. + +You can use this function in LIPS with version 5 and 7 to get R5RS or R7RS. + +**NOTE**: that some of the functions from R5RS may have features of R7RS since +some of them got additional arguments. RnRS is backward compatible. + +You can use this function with `eval` or `let-env`: + +```scheme +(let ((env (scheme-report-environment 7))) + (let-env env + (display (+ 1 2)))) +;; ==> 3 +(let-env (scheme-report-environment 7) + (display (--> "string" (toUpperCase)))) +;; ==> Unbound variable `-->' +(let-env (scheme-report-environment 7) + (write (vector-map + #(1 2 3) #(4 5 6 7)))) +;; ==> #(5 7 9) +(let-env (scheme-report-environment 5) + (write (vector-map + #(1 2 3) #(4 5 6 7)))) +;; ==> Unbound variable `vector-map' +``` + +R5RS doesn't support `vector-map` that was added in version R7RS. The same +both Scheme versions doesn't support LIPS extensions like [`-->` +macro](/docs/lips/intro#helper-macros-and-functions). + ## Introspection -Since environments are JavaScript objects you can access it's properties like `__name__` or `__env__`. +Since environments are JavaScript objects you can access its properties like `__name__` or `__env__`. ```scheme (let ((x 10) (y 20))