[racket] Delimiting scope

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sat Jan 18 14:51:13 EST 2014

Hi Antoine,

Here is one attempt:

(define-syntax (delimit-scope stx)
  (syntax-case stx ()
    [(_ form)
     ((make-syntax-introducer)
      (datum->syntax #'here (syntax->datum #'form)))]))

/Jens Axel



2014/1/18 antoine <antoine.brand at sfr.fr>:
> Bonjour,
>
> Is there a way to delimit scope?
>
> example:
> (let ([a 1])
>   (delimit-scope
>     (let ([b 1])
>       (+ a b))))
> Give an error of the form 'a: undefined;'
>
> I use the include-template from web-server/templates in a way like:
> (response/output
>   (lambda (out)
>     (display
>       (include-template "my-template.html")
>       out)))
>
> "my-template.html" may also use include-template and i don't want an unexpected
> bindings being used, i want to make bindings explicit.
>
> I could use
> (let ([my-bindings....])  (include-template "my-template.html"))
> but this isn't sufficient for prevent upper bindings from let form being used.
>
>
> Another point totally different.
>
> In racket there is a lot of functions like response/output that take a function
> in parameter that take n-parameters.
> Why not use a macro unhygienic that introduce those n-bindings but allow user to
> rename the bindings names:
> (response/output
>   #:out-binding 'abc
>   (display "something" abc))
>
> (response/output
>   (display "something" out))
>
>
> Thank you.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



-- 
--
Jens Axel Søgaard


Posted on the users mailing list.