Email list hosting service & mailing list manager

put library <body> at top-level Per Bothner (30 Nov 2005 20:33 UTC)
(missing)
(missing)
(missing)
(missing)
Re: put library <body> at top-level Per Bothner (03 Dec 2005 16:16 UTC)
Re: put library <body> at top-level Ray Blaak (03 Dec 2005 16:17 UTC)
import suggestion Ray Blaak (03 Dec 2005 16:17 UTC)
Re: put library <body> at top-level Matthew Flatt (30 Nov 2005 22:20 UTC)
Re: put library <body> at top-level Per Bothner (30 Nov 2005 22:29 UTC)
Re: put library <body> at top-level Bradd W. Szonye (03 Dec 2005 16:16 UTC)

Re: put library <body> at top-level Bradd W. Szonye 01 Dec 2005 18:15 UTC

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