import concerns (was Re: Historical language survey)

Derek Parnell derek at psych.ward
Sat Jul 8 01:28:45 PDT 2006


On Sat, 08 Jul 2006 18:23:09 +1000, Walter Bright  
<newshound at digitalmars.com> wrote:

> Walter Bright wrote:
>>>> What can also be done is extend the import declaration to allow the  
>>>> .'s to continue so that specific symbols can be imported.
>>>
>>> Now that would be great. I believe selective-importing (as an option)  
>>> would be a boon in a number of ways ~ and would resolve this issue  
>>> quite elegantly.
>>  I like this one better, too.
>
> There's another way - have a different kind of import declaration, say,  
> precede it with static:
>
> 	static import foo;
>
> which will make the symbols in foo available, but only if they are  
> explicitly qualified. Then one could access bar in foo by either:
>
> 	foo.bar();
>
> or:
>
> 	alias foo.bar bar;
> 	bar();
>
> but not:
>
> 	bar();	// error, undefined symbol
>
> The advantage of this is it is a bit more flexible and more consistent  
> with the way the rest of D lookups work.

Nice. But only if foo.bar is not private. If its private the caller should  
not be able to call it.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d mailing list