[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: put library <body> at top-level



Per Bothner wrote:
> I don't see any rationale for:
> 
> (library <lib-path> <language>
>      <body>)
> 
> rather than identitying a library with a file, as in:
> 
> (library <lib-path> <language>)
> <body>
> 
> The former is syntactically awkward ....

I've used the first ("scoped") syntax, for MzScheme's module system. I
did find it useful for experimenting with library code -- learning how
the system works, prototyping libraries, that sort of thing -- because
it allowed me to test overall system structure in a single small file.
However, it quickly became annoying when I expanded the code, largely
because Vim's syntax highlighting and auto-indenting don't handle
massive indented scopes well.

For performance reasons, Vim's syntax tools depend on "synchronization
points," places in the code where you can /lexically/ determine scope.
That works well for most languages in the LISP and Algol families,
because major functions and comments are usually both (1) unindented and
(2) in the outermost scope. Placing entire libraries inside a syntactic
scope defeats this feature, which means that Vim must analyze the whole
library (awful performance) or get out of sync with the code (awful
highlighting and indenting). It's especially bad if you need to insert
code in the middle of an existing scope.

In the past, I've dealt with this by leaving the library code
unindented, as if it were the top level, but then the indenter gets
confused near the start of the library (because it wants to indent the
library "properly").

So while I see some advantages to an explicit scope/grouping syntax for
library code, it causes major annoyances when using my everyday tools on
realistically-sized projects.
-- 
Bradd W. Szonye
http://www.szonye.com/bradd