Feature Request: Import As (e.g. import java.sql.Connection as SqlConnection)

Oliver Ruebenacker curoli at gmail.com
Fri Apr 1 13:23:47 UTC 2016


     Hello,

  Here is how Scala does it:

The clause makes available without qualification.. import p._ all members
of p (this is analogous to *import* p.* in Java). import p.x the member x
 of p. import p.{x *=>* a} the member x of p renamed as a. import p.{x, y}
the members x and y of p. import p1.p2.z the member z of p2, itself member
of p1.
     Best, Oliver

On Fri, Apr 1, 2016 at 12:48 AM, Christoph Engelbert <me at noctarius.com>
wrote:

> Hey Behrang,
>
> Yeah I like the idea, anyhow you know new keywords and Java is not going
> to be friends :) However you could do something like:
>
> import java.sql.Connection : SqlConnection;
> or
> import SqlConnection = java.sql.Connection;
>
> There are most possible tons of other possibilities. I also like the
> option in Dlang to import multiple classes from the same package in a
> single line: https://dlang.org/spec/module.html#selective_imports <
> https://dlang.org/spec/module.html#selective_imports>
>
> Cheers,
> Chris
>
> > On 01 Apr 2016, at 06:33, Behrang Saeedzadeh <behrangsa at gmail.com>
> wrote:
> >
> > Hi all,
> >
> > Any thoughts on this feature? I think it should be relatively simple to
> > implement and considering these days an app might use various types of
> data
> > storage as well as queues, etc. it is very likely for two classes with
> the
> > same name but from different packages need to be used in a given class.
> >
> > This could be extended to imported static methods too, because sometimes
> > their names are ambiguous if they are not prefixed with their respective
> > classes.
> >
> > import static java.lang.String.format as stringFormat;
> > // or
> > import static java.lang.String.format as sformat;
> > // or
> > import static java.lang.String.format as formats;
> >
> > Best regards,
> > Behrang Saeedzadeh
>
>


-- 
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal
<http://www.type2diabetesgenetics.org/>, Broad Institute
<http://www.broadinstitute.org/>


More information about the discuss mailing list