[racket] web-server/templates: "require: not at module level or top level"

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Nov 27 11:37:00 EST 2013

First, local-require can only get phase-0 bindings.

Second, there is a slight code-size penalty if you look at the
expansion, because local-require lifts the require to the top-level
and then enumerates the phase-0 bindings with the same ids but the
lexical context of the local-require body.

As for why we can't just have "require" in a non-top-level context
turn into local-require... I think the first point is the significant
one, because you might be confused about what bindings you could get,
so it's useful to make sure you know that you're just doing a local
version.

I'm surprised that people don't know about local-require... it is
documented on the same page as require.

On Wed, Nov 27, 2013 at 9:30 AM, Greg Hendershott
<greghendershott at gmail.com> wrote:
> So I have a delayed-reaction question.
>
> Why separate `require` and `local-require`?
>
> It looks like `local-require` works at module level or top level; it
> _seems_ equivalent to `require` there.
>
> Why not just have `require` _be_ `local-require`?
>
> Or is there some cost or penalty to `local-require` that makes it
> worthwhile to have available and use the limited `require`?
>
>
> On Tue, Nov 26, 2013 at 6:43 PM, Greg Hendershott
> <greghendershott at gmail.com> wrote:
>>> Of course, local-require works fine because local-require can go at
>>> any scope and position.
>>
>> I didn't know about `local-require`.
>>
>> I tried and it works perfectly. Thanks!



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.