[plt-scheme] let-require

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Mon Nov 2 13:24:54 EST 2009

I provide this in a planet package:

--
#lang scheme

(require (planet cce/scheme:6))

(define (make-weird-list a b c)
  (local-require srfi/1)
  (circular-list a b c))

(define (circular-list . args)
  (error "Never gets here"))

(make-weird-list 1 2 3)
--

Carl Eastlund

On Mon, Nov 2, 2009 at 1:13 PM, Synx <plt at synx.us.to> wrote:
>
> You know what would be awesome? A syntax that lets you require a module
> but limits the lexical scope of its provided names. Something like:
>
> ---
> (define (make-weird-list a b c)
>  (let-require (srfi/1)
>    (circular-list a b c)))
>
> (define (circular-list . args)
>  (error "Never gets here"))
>
> (make-weird-list 1 2 3)
> ---
>
> or one thing I was thinking is to allow multiple modules in one file,
> yet only the one named according to the file name is available from
> external files.
>
> weird-list.ss
> ---
> (module backstage scheme/base
>  (require srfi/1)
>  (define (make-thing a b c)
>    (circular-list a b c))
>  (provide make-thing))
>
> (module weird-list scheme/base
>  (require backstage)
>  (define (main)
>    (make-thing 1 2 3))
>  (provide main))
> ---
>
> I like the let-require idea better though. Is there a reason that
> require must introduce names at the module's lexical scope? Or is there
> a way to do it already that I don't know about?


Posted on the users mailing list.