On Mon, Feb 1, 2010 at 10:09 PM, Allen Wirfs-Brock
<[email protected]> wrote:
>> import X as ...;
>> import Y as ...;
>>
>> function f1() { /* operate on the authorities of 'X' */ }
>> function f2() { /* operate on the authorities of 'Y' */ }
>>
>> In this fashion, I cannot limit, via lexical scope, that f1 operates
>> on X but not Y, and that f2 operates on Y but not X.
>
> But the above four lines are all in the same module, that is in the same unit
> of source code.
Yes, but there's a difference. Consider the following:
import X as x;
import Y as y;
function f1() { /* deeply nested structure */ }
function f2() { /* deeply nested structure */ }
It is very difficult to tell whether f1() limits its authority to
using X, and f2() to using Y. Now consider:
import X as x;
import Y as y;
(import 'f1')({ x: x });
(import 'f2')({ y: y });
This is much clearer. Alternatively:
import X as x;
import Y as y;
module f1(x) { /* deeply nested structure */ }
module f1(y) { /* deeply nested structure */ }
f1({ x: x });
f2({ y: y });
achieves the same purpose, given that the 'module' keyword cuts the
lexical scope.
Absent syntactic bikeshedding (for which there will be plenty of time
:) ...) what I'm trying to show here is that a good module system
*helps* you divide up your lexical scope.
Ihab
--
Ihab A.B. Awad, Palo Alto, CA
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss