Import concerns revisited

xs0 xs0 at xs0.com
Wed Jul 12 03:55:10 PDT 2006


Walter Bright wrote:
> Lars Ivar Igesund wrote:
>> Walter Bright wrote:
>>
>>> Lars Ivar Igesund wrote:
>>>> Well, who did ever say that was a good idea, everything public by
>>>> default? ;)
>>> I did <g>.
>>
>> Right :) I don't agree.
> 
> Let me explain why I think default public is a good idea.

For the general case (classes/functions/etc.), I'd say both private and 
public defaults have their advantages and disadvantages, so OK, but I'd 
still like you to reconsider imports.


> It reduces clutter in sample, example, and quick programs. Access 
> security is an advanced feature, one that's invaluable for a complex 
> project, but is just in the way for smaller ones.

In single-module programs, it doesn't matter either way
In multiple-module programs (both small and large), the clutter is 
greater than it would be if imports were private by default.


> And it's just plain irritating when writing smaller programs where 
> access control is quite irrelevant.

Exactly. Yet you force us to declare imports private as soon as more 
than one module is used.

You seem to miss the obvious fact that most imports serve a module's 
implementation, not its interface..


BTW, in any case neither the current "import foo" nor potential "public 
import foo" don't really indicate what they do, at least to me.. how about:

import foo;         // currently "private import foo;"
import/export foo;  // currently "import foo;"

Don't take that too seriously, but it would make things far more obvious...


xs0



More information about the Digitalmars-d mailing list