I'm not seeing the less friendly... Eval, and sandboxing eval, are builtin features of the Scheme standard.
((eval `(lambda (foo) ,exp) (scheme-report-environment 5))
foo)
(can't really think of applications for getting the current environment right now except for pseudo-macro stuff)If you want to manipulate the current environment, and defeat half the point of the language, then you're allowed that through (user-initial-environment).
(define-syntax) will also let you rewrite the bindings however you require.
Edit: Here's an eval macro I use fairly often:
(define-syntax constexpr
(syntax-rules ()
((_ expr)
(begin
(syntax->datum
(datum->syntax
(quote-syntax here)
(eval 'expr (interaction-environment))))))))
(define (factorial n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
(define n
(constexpr (factorial 10)))That's why SRFI-49 and its descendants were a possibility. Wisp, JavaScript, brainfuck, etc. implementations all exist because the tools exist in the language.
https://conservatory.scheme.org/schemers/Documents/Standards...
Not that I know why eval should be paired with reader macros.