Comment

Comment by shakna

Scheme is hygeneic, yes. Which is why sandboxing works.

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)))
parent shakna 2 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton