It is useful to place the contents of a module within a block so that 'let' at the top-level can be used
to provide a module scope, reducing pollution of the global namespace, and allowing modules to have
'private' or 'internal' components.
The down-side is that the entire module is indented within the block, which is ugly and wastes a valuable
indentation level.
It would be nice if require() could be modified to automatically place the contents of modules within a
block so that 'let' could be used at the top level, providing an automatic module scope.
My naive suggestion was to read module contents into a string buffer, stick '{' at the beginning and '}'
at the end, and evaluate the buffer, but jbms points out that this eliminates file and line number
information from stack traces.
Come up with a way to do this without sacrificing file and line number data.
|