Import improvement

1100110 0b1100110 at gmail.com
Mon Oct 15 16:39:20 PDT 2012


On Mon, 15 Oct 2012 13:38:31 -0500, Chris Nicholson-Sauls  
<ibisbasenji at gmail.com> wrote:

> On Monday, 15 October 2012 at 15:37:06 UTC, Andrei Alexandrescu wrote:
>> I don't think imports from a specific package have been considered.
>>
>> In my personal opinion, imports are a necessary evil and it's sort of a  
>> bummer that the most accessible place in any source file - the top  
>> lines - is occupied by the crappy legal disclaimer (which, after having  
>> talked to a lawyer, I always put at the bottom since being at the top  
>> is not a requirement), and the litany of imports that the module is  
>> using. I'd make all imports local or put them at the bottom of the file  
>> if it weren't too much of a shock to others.
>>
>> Three remarks on this particular problem.
>>
>> 1. I expect large packages to introduce a module "all.di" or "_.di" to  
>> publicly import everything in the package. That could help some use  
>> cases.
>
> It is a common practice (usually all.di) but perhaps it could help to  
> establish an official convention.  Nothing in the language, just the  
> styleguide.  (I know this has already come up and been discussed.)

I like what vibe.d did by having an import all file named d.d

Therefore you can:
import vibe.d;

It's nice, it's clean, and I've blatantly stolen it for a few of my own  
projects.


More information about the Digitalmars-d mailing list