Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18693 > unrolled thread

import order

Started bybob smith <bob@coolfone.comze.com>
First post2012-09-12 13:21 -0700
Last post2012-09-12 17:35 -0400
Articles 13 — 5 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  import order bob smith <bob@coolfone.comze.com> - 2012-09-12 13:21 -0700
    Re: import order Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 16:27 -0400
    Re: import order Martin Gregorie <martin@address-in-sig.invalid> - 2012-09-12 20:38 +0000
      Re: import order Lew <lewbloch@gmail.com> - 2012-09-12 14:30 -0700
        Re: import order Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 17:37 -0400
          Re: import order Lew <lewbloch@gmail.com> - 2012-09-12 14:48 -0700
            Re: import order Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 17:55 -0400
              Re: import order Lew <lewbloch@gmail.com> - 2012-09-12 22:36 -0700
    Re: import order Robert Klemme <shortcutter@googlemail.com> - 2012-09-12 23:27 +0200
      Re: import order Lew <lewbloch@gmail.com> - 2012-09-12 14:31 -0700
        Re: import order Martin Gregorie <martin@address-in-sig.invalid> - 2012-09-12 21:53 +0000
          Re: import order Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:01 -0400
      Re: import order Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 17:35 -0400

#18693 — import order

Frombob smith <bob@coolfone.comze.com>
Date2012-09-12 13:21 -0700
Subjectimport order
Message-ID<c15a6122-257c-4e8a-bb11-9c7684d5d222@googlegroups.com>
Does order ever matter with import statements in Java?

I don't think so.

I noticed it does sometimes matter with C++.  Why the difference?

[toc] | [next] | [standalone]


#18694

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-09-12 16:27 -0400
Message-ID<5050f031$0$293$14726298@news.sunsite.dk>
In reply to#18693
On 9/12/2012 4:21 PM, bob smith wrote:
> Does order ever matter with import statements in Java?
>
> I don't think so.

Correct.

If there is a conflict you get an error.

> I noticed it does sometimes matter with C++.  Why the difference?

Weird. I thought C++ also gave errors in case of a conflict.

Arne

[toc] | [prev] | [next] | [standalone]


#18695

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2012-09-12 20:38 +0000
Message-ID<k2qrs2$tg2$1@localhost.localdomain>
In reply to#18693
On Wed, 12 Sep 2012 13:21:25 -0700, bob smith wrote:

> Does order ever matter with import statements in Java?
> 
> I don't think so.
> 
> I noticed it does sometimes matter with C++.  Why the difference?
>
C/C++ #include statements can, and often do, contain further nested 
#includes, so its quite possible that not all of these will be inside the 
#ifndef ... #endif brackets that should check for and skip multiple 
inclusions. 

Since, unlike a C/C++ #include statement, an import doesn't pull in any 
source code, Java can never have this sort of clash.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

[toc] | [prev] | [next] | [standalone]


#18698

FromLew <lewbloch@gmail.com>
Date2012-09-12 14:30 -0700
Message-ID<27de199c-6cf5-4795-9607-767971559344@googlegroups.com>
In reply to#18695
Martin Gregorie wrote:
> bob smith wrote:
>> Does order ever matter with import statements in Java?
>> I don't think so.
>> I noticed it does sometimes matter with C++.  Why the difference?

C++ import directives (not statements!) are not the same as Java import directives.

C++ import directives pull in type libraries. Java import directives identify textual 
aliases for fully-qualified class names.

> C/C++ #include statements can, and often do, contain further nested 
> #includes, so its quite possible that not all of these will be inside the 
> #ifndef ... #endif brackets that should check for and skip multiple 
> inclusions. 

He asked about import "statements". He didn't mention '#include'.

C++ has an import directive:
http://msdn.microsoft.com/en-us/library/8etzzkb6(v=vs.71).aspx

That said, if the OP did mean '#include' your comments are on the mark.

> Since, unlike a C/C++ #include statement, an import doesn't pull in any 
> source code, Java can never have this sort of clash.

Java 'import' and C++ '#include' are not the same thing at all. What Martin 
tells you here is the difference.

Does source code order matter? Of course it does, and that's why '#include' 
order matters, and Java 'import' order doesn't.

Whether you say it first, fourth or seventeenth, if you import 'List' as an alias
for 'java.util.List', it will alias that FQN (fully-qualified name).

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#18701

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-09-12 17:37 -0400
Message-ID<5051007f$0$287$14726298@news.sunsite.dk>
In reply to#18698
On 9/12/2012 5:30 PM, Lew wrote:
> Martin Gregorie wrote:
>> bob smith wrote:
>>> Does order ever matter with import statements in Java?
>>> I don't think so.
>>> I noticed it does sometimes matter with C++.  Why the difference?
>
> C++ import directives (not statements!) are not the same as Java import directives.
>
> C++ import directives pull in type libraries. Java import directives identify textual
> aliases for fully-qualified class names.
>
>> C/C++ #include statements can, and often do, contain further nested
>> #includes, so its quite possible that not all of these will be inside the
>> #ifndef ... #endif brackets that should check for and skip multiple
>> inclusions.
>
> He asked about import "statements". He didn't mention '#include'.
>
> C++ has an import directive:
> http://msdn.microsoft.com/en-us/library/8etzzkb6(v=vs.71).aspx

C++ does not.

MS C++ has.

Arne

[toc] | [prev] | [next] | [standalone]


#18702

FromLew <lewbloch@gmail.com>
Date2012-09-12 14:48 -0700
Message-ID<8c077afa-b754-41d0-8154-41683a42e42e@googlegroups.com>
In reply to#18701
Arne Vajhøj wrote:
>  Lew wrote:
>> C++ has an import directive:
>> http://msdn.microsoft.com/en-us/library/8etzzkb6(v=vs.71).aspx
> 
> C++ does not.
> 
> MS C++ has.

Potayto, potahto.

At least one flavor of C++ has it, so C++ has it, somewhere, albeit as you point out, 
not portably.

But then C++ isn't that portable anyway.

Perhaps the OP can tell us which of '#import', '#include' and 'using' he actually meant.

The answer remains much the same regardless - C++ is not Java. Java's 'import' is 
not the same as any of those three C++ (-related) concepts.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#18704

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-09-12 17:55 -0400
Message-ID<505104ef$0$286$14726298@news.sunsite.dk>
In reply to#18702
On 9/12/2012 5:48 PM, Lew wrote:
> Arne Vajhøj wrote:
>>   Lew wrote:
>>> C++ has an import directive:
>>> http://msdn.microsoft.com/en-us/library/8etzzkb6(v=vs.71).aspx
>>
>> C++ does not.
>>
>> MS C++ has.
>
> Potayto, potahto.
>
> At least one flavor of C++ has it, so C++ has it, somewhere, albeit as you point out,
> not portably.

Not in the C++ specification (ISO).

> Perhaps the OP can tell us which of '#import', '#include' and 'using' he actually meant.
>
> The answer remains much the same regardless - C++ is not Java. Java's 'import' is
> not the same as any of those three C++ (-related) concepts.

The difference between Java import and C++ using are slim. The only
difference I can think of is syntax (statement itself and where it is
legal).

Arne

[toc] | [prev] | [next] | [standalone]


#18723

FromLew <lewbloch@gmail.com>
Date2012-09-12 22:36 -0700
Message-ID<5073a29b-0fba-422c-a54f-7c749d76c85d@googlegroups.com>
In reply to#18704
Arne Vajhøj wrote:
> The difference between Java import and C++ using are slim. The only
> difference I can think of is syntax (statement itself and where it is
> legal).

Yes, you are right. I stand corrected.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#18697

FromRobert Klemme <shortcutter@googlemail.com>
Date2012-09-12 23:27 +0200
Message-ID<abcd2eF8mgbU2@mid.individual.net>
In reply to#18693
On 12.09.2012 22:21, bob smith wrote:
> Does order ever matter with import statements in Java?
>
> I don't think so.
>
> I noticed it does sometimes matter with C++.  Why the difference?

C++ does not have import statements - as simple as that.

If you are referring to #include then we are talking about two 
dramatically different mechanisms (don't let yourself be fooled of the 
fact that both mechanisms are used to achieve similar goals).

Cheers

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

[toc] | [prev] | [next] | [standalone]


#18699

FromLew <lewbloch@gmail.com>
Date2012-09-12 14:31 -0700
Message-ID<3a82498e-61e5-4438-b665-3d60b170dce0@googlegroups.com>
In reply to#18697
Robert Klemme wrote:
> bob smith wrote:
>> Does order ever matter with import statements in Java?
> 
>> I don't think so.
>> I noticed it does sometimes matter with C++.  Why the difference?

> C++ does not have import statements - as simple as that.

But it does have an '#import' directive, at least in the MS world.
http://msdn.microsoft.com/en-us/library/8etzzkb6(v=vs.71).aspx

> If you are referring to #include then we are talking about two 
> dramatically different mechanisms (don't let yourself be fooled of the 
> fact that both mechanisms are used to achieve similar goals).

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#18703

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2012-09-12 21:53 +0000
Message-ID<k2r09f$uon$1@localhost.localdomain>
In reply to#18699
On Wed, 12 Sep 2012 14:31:59 -0700, Lew wrote:

> Robert Klemme wrote:
>> bob smith wrote:
>>> Does order ever matter with import statements in Java?
>> 
>>> I don't think so.
>>> I noticed it does sometimes matter with C++.  Why the difference?
> 
>> C++ does not have import statements - as simple as that.
> 
> But it does have an '#import' directive, at least in the MS world.
> http://msdn.microsoft.com/en-us/library/8etzzkb6(v=vs.71).aspx
>
Thanks for the link: I've never used MS C/C++ compilers, so #import was 
news to me. 

That said, it appears that #import pulls in and/or generates some sort of 
proprietary type definition file plus an #include file. So, it would 
appear that #import would suffer from exactly the same ordering problems 
as #include does.
  

-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

[toc] | [prev] | [next] | [standalone]


#18705

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-09-12 18:01 -0400
Message-ID<50510652$0$286$14726298@news.sunsite.dk>
In reply to#18703
On 9/12/2012 5:53 PM, Martin Gregorie wrote:
> On Wed, 12 Sep 2012 14:31:59 -0700, Lew wrote:
>
>> Robert Klemme wrote:
>>> bob smith wrote:
>>>> Does order ever matter with import statements in Java?
>>>
>>>> I don't think so.
>>>> I noticed it does sometimes matter with C++.  Why the difference?
>>
>>> C++ does not have import statements - as simple as that.
>>
>> But it does have an '#import' directive, at least in the MS world.
>> http://msdn.microsoft.com/en-us/library/8etzzkb6(v=vs.71).aspx
>>
> Thanks for the link: I've never used MS C/C++ compilers, so #import was
> news to me.
>
> That said, it appears that #import pulls in and/or generates some sort of
> proprietary type definition file plus an #include file. So, it would
> appear that #import would suffer from exactly the same ordering problems
> as #include does.

It imports a COM type library.

But yes - it is also order specific.

Arne


[toc] | [prev] | [next] | [standalone]


#18700

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-09-12 17:35 -0400
Message-ID<50510039$0$287$14726298@news.sunsite.dk>
In reply to#18697
On 9/12/2012 5:27 PM, Robert Klemme wrote:
> On 12.09.2012 22:21, bob smith wrote:
>> Does order ever matter with import statements in Java?
>>
>> I don't think so.
>>
>> I noticed it does sometimes matter with C++.  Why the difference?
>
> C++ does not have import statements - as simple as that.
>
> If you are referring to #include then we are talking about two
> dramatically different mechanisms (don't let yourself be fooled of the
> fact that both mechanisms are used to achieve similar goals).

I assumed that he was talking about C++ using, which is doing
the same as Java import.

Arne

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web