Feature request: aliasing classes at import

Marek Kozieł develop4lasu at gmail.com
Tue Aug 16 12:54:43 PDT 2011


2011/8/16 saeed yousefi <saeedtej at yahoo.com>:
>>The only way I can now think about aliases is to exist and not make life
>>harder: limit them to partially qualified classes with some
>>prefix/suffix like '...': >import x.y.z.w.ClassName as ...y.ClassName;
>>import a.b.z.w.ClassName as ...b.ClassName; >or >import x.y.z.w.ClassName as ...x.y.ClassName;
>>import a.b.z.w.ClassName as ...a.b.ClassName; >or >import x.y.z.w.ClassName as ...y.ClassName; // y is characteristic
>>import a.b.z.w.ClassName as ...a.ClassName; // a is characteristic
> you mean  , it would be for instance  for Date class  (if we make use of  dot prefix) :
> import java.util.Date as .util.Date; import java.sql.Date as .sql.Date;
>
> nice idea :)
>
>

Hello,

I consider dot prefix(.) as inappropriate because it is  currently used:
labels.setAlignAsToRight()//
     .setX(1).setHorMarginX(5, 0, 10);
 fields.setAlignAsToLeft()//
     .setX(3).setHorMarginX(5, 0, 5);

I think that java.util.Date is a pretty short and it would be hard to
notice if solution is good or bad. Any way:


     .util.Date
would bring confusion and make us wander if we had to check previous line.
because smf like:
object.getElement().count//
     .util.Date
could appear!

     '..' - better but it's so similar with '.' and its meaning would
be considered as being near with dot (operator). Moreover, seeing dot
at the end of the line and then second (dot) on start of another could
not bring suspicious in instant.

    '...' - a lot of ppl find it as skipped/progress/search so
it(...util.Date) would be 'naturally' read as  searching for Date in
some util package.

Any way, I have mixed fillings about that solution.

Line of code like:
     ...db.Conector.Util.start(...);
could make some programmers to wander if Util or Conector is class. I
know it would be in a bad style, but still Java should consider that
as well.
Maybe ensuring space after alias with formatter could help:
     ...db.Conector .Util.start(...);

-- 
Regards.
Lasu aka Marek Kozieł        http://lasu2string.blogspot.com/


More information about the jdk8-dev mailing list