On 14 Oct 2009, at 9:37 am, Ray Dillinger wrote:
> I think lambda's not quite right because it provides only nested
> scopes.
>
> Firstly there's a nesting depth beyond which I'm uncomfortable.
>
> Secondly there's sometimes a need for a scope visible in places
> separated by other places where it's not visible.

Oh, you can do all that stuff (apart from macros, as they're not
values, but there's ways to deal with that) - you can treat a 'module'
as a closure that accepts a closure and applies it to the contents of
the module... like this:

(define my-silly-addition-module
   (lambda (body)
     (body
       (lambda (a b) (+ a b 1)) ; here we define everything our module
exports
   )))

Clearly, we can have some private internal bindings in the module, by
wrapping the outer lambda in a let.

....then to use the module, we apply it...

(my-silly-addition-module
    (lambda (silly-add) ; declare your imports here
        (silly-add 1 2)))

The user of the module needs to explicitly declare all the symbols
they want (and even the ones they don't!), but these lambda-modules
give you full arbitrary renaming capability on import :-)

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/archives/author/alaric/




_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to