Task

Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.




(define-syntax define-constant
  (syntax-rules ()
    ((_ id v)
     (begin
       (define _id v)
       (define-syntax id
         (make-variable-transformer
          (lambda (stx)
            (syntax-case stx (set!)
              ((set! id _)
               (raise
                (syntax-violation
                 'set! "Cannot redefine constant" stx #'id)))
              ((id . args) #'(_id . args))
              (id #'_id)))))))))