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


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

Re: Why “new”?

Started by"Mike Schilling" <mscottschilling@hotmail.com>
First post2011-02-04 18:27 -0800
Last post2011-02-05 01:25 -0500
Articles 20 — 8 participants

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Why “new”? "Mike Schilling" <mscottschilling@hotmail.com> - 2011-02-04 18:27 -0800
    Re: Why “new”? Lars Enderin <lars.enderin@telia.com> - 2011-02-05 18:04 +0100
    Re: Why “new”? "Mike Schilling" <mscottschilling@hotmail.com> - 2011-02-05 02:49 -0800
      Re: Why “new”? Lew <noone@lewscanon.com> - 2011-02-05 09:14 -0500
    Re: Why “new”? Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-05 20:42 +1300
      Re: Why “new”? Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 20:46 -0500
      Re: Why “new”? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-05 10:38 -0500
      Re: Why “new”? Lew <noone@lewscanon.com> - 2011-02-05 09:13 -0500
    Re: Why “new”? jlp <jlp@jlp.com> - 2011-02-05 08:31 +0100
      Re: Why “new”? Lew <noone@lewscanon.com> - 2011-02-05 09:08 -0500
    Re: Why “new”? Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 20:44 -0500
    Re: Why “new”? Lew <noone@lewscanon.com> - 2011-02-05 09:07 -0500
    Re: Why “new”? Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-05 16:51 +1300
      Re: Why “new”? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-04 23:06 -0500
      Re: Why “new”? Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-05 19:45 +1300
        Re: Why “new”? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-05 10:32 -0500
      Re: Why “new”? Lew <noone@lewscanon.com> - 2011-02-04 23:40 -0500
      Re: Why “new”? Arne Vajhøj <arne@vajhoej.dk> - 2011-02-07 19:15 -0500
    Re: Why “new”? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2011-02-04 21:31 -0800
      Re: Why “new”? Lew <noone@lewscanon.com> - 2011-02-05 01:25 -0500

#25516 — Re: Why “new”?

From"Mike Schilling" <mscottschilling@hotmail.com>
Date2011-02-04 18:27 -0800
SubjectRe: Why “new”?
Message-ID<iiicja$epf$1@news.eternal-september.org>

"Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in message 
news:iiiaia$5t9$1@lust.ihug.co.nz...
> In message <iii9dq$3pr$1@news.eternal-september.org>, Mike Schilling 
> wrote:
>
>> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in message
>> news:iii8s4$4tt$1@lust.ihug.co.nz...
>>>
>>> You already have that confusion, when every method declaration in Java 
>>> is
>>> effectively virtual, unlike C++.
>>
>> That's not true, you know.
>
> No, I don’t know. Please explain.

Private methods are not virtual, nor are static methods. 

[toc] | [next] | [standalone]


#25531

FromLars Enderin <lars.enderin@telia.com>
Date2011-02-05 18:04 +0100
Message-ID<4D4D8306.5030304@telia.com>
In reply to#25516
2011-02-05 15:07, Lew skrev:
> Lew wrote:
>>> Reference to the C++ spec sheds absolutely no light whatsoever on Java.
> 
> Lawrence D'Oliveiro wrote:
>> That’s where the term “virtual” comes from.
> 
> No, that is completely mistaken.  C++ adopted the term because it used
> the technique.  Smalltalk had it before C++.

I am sure Bjarne Stroustrup took "virtual" from SIMULA (67), which
preceded Smalltalk.He based C++ on C and SIMULA. I have heard him talk
about that.

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


#25589

From"Mike Schilling" <mscottschilling@hotmail.com>
Date2011-02-05 02:49 -0800
Message-ID<iij9v9$8ob$1@news.eternal-september.org>
In reply to#25516

"Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in message 
news:iiiv1k$hgg$1@lust.ihug.co.nz...
> In message <iiiqgj$46f$1@news.albasani.net>, Lew wrote:
>
>> Virtual methods always belong to an instance, so they can never be 
>> static.
>
> Considering that “virtual” is a concept defined by C++, and C++ doesn’t
> define it that way...

Ah, so you know as little about C++ as you do about Java. 

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


#25746

FromLew <noone@lewscanon.com>
Date2011-02-05 09:14 -0500
Message-ID<iijm06$alb$2@news.albasani.net>
In reply to#25589
On 02/05/2011 05:49 AM, Mike Schilling wrote:
>
>
> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in message
> news:iiiv1k$hgg$1@lust.ihug.co.nz...
>> In message <iiiqgj$46f$1@news.albasani.net>, Lew wrote:
>>
>>> Virtual methods always belong to an instance, so they can never be static.
>>
>> Considering that “virtual” is a concept defined by C++, and C++ doesn’t
>> define it that way...
>
> Ah, so you know as little about C++ as you do about Java.

And doomed to remain that way since he won't read references, won't listen to 
reason and won't accept logic.

-- 
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/  | *\##|
|#/ * |   \#|
|#----|----#|
||    |  * ||
|o *  |    o|
|_____|_____|
|===========|

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


#25624

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-02-05 20:42 +1300
Message-ID<iiiv1k$hgg$1@lust.ihug.co.nz>
In reply to#25516
In message <iiiqgj$46f$1@news.albasani.net>, Lew wrote:

> Virtual methods always belong to an instance, so they can never be static.

Considering that “virtual” is a concept defined by C++, and C++ doesn’t 
define it that way...

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


#25632

FromArne Vajhøj <arne@vajhoej.dk>
Date2011-02-06 20:46 -0500
Message-ID<4d4f4eea$0$23755$14726298@news.sunsite.dk>
In reply to#25624
On 05-02-2011 02:42, Lawrence D'Oliveiro wrote:
> In message<iiiqgj$46f$1@news.albasani.net>, Lew wrote:
>> Virtual methods always belong to an instance, so they can never be static.
>
> Considering that “virtual” is a concept defined by C++,

It is not.

It is a general concept in OOP.

Arne

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


#25839

FromJoshua Cranmer <Pidgeot18@verizon.invalid>
Date2011-02-05 10:38 -0500
Message-ID<iijqtc$7a4$2@news.eternal-september.org>
In reply to#25624
On 02/05/2011 02:42 AM, Lawrence D'Oliveiro wrote:
> In message<iiiqgj$46f$1@news.albasani.net>, Lew wrote:
>
>> Virtual methods always belong to an instance, so they can never be static.
>
> Considering that “virtual” is a concept defined by C++, and C++ doesn’t
> define it that way...

Dynamic method dispatch has existed since Simula (long before C++ or 
even C), which was, incidentally, the first language to use virtual, to 
my knowledge.

It doesn't matter how *C++* defines it if you're talking about *Java*. 
C++ defines an int as follows:

Plain ints have the natural size suggested by the architecture of the 
execution environment; the other signed integer types are provided to 
meet special needs.

So, obviously, Java ints must act the same way, by your logic. But they 
don't.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

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


#26068

FromLew <noone@lewscanon.com>
Date2011-02-05 09:13 -0500
Message-ID<iijlv4$alb$1@news.albasani.net>
In reply to#25624
Lawrence D'Oliveiro wrote:
> Considering that “virtual” is a concept defined by C++, and C++ doesn’t
> define it that way...

Again, wrong.  The concept pre-dates C++ and is defined in several languages 
both before and since.  C++ definitions are completely irrelevant to Java.  In 
case you haven't noticed, THEY'RE DIFFERENT LANGUAGES!

Next you'll try to make the claim that Java "references" aren't what they are 
because the term means something different in C++.  It's a stupid argument.

THEY'RE DIFFERENT LANGUAGES!  You cannot use C++ definitions for Java.  You 
can use industry terminology, of course, and "virtual function" is not limited 
to C++.  You've been given two Wikipedia links that explain that.  You might 
want to consider actually reading them and correcting your wrong-headed notions.

Smalltalk had virtual methods years before C++.  C++ didn't invent the idea.

Simply stating the same wrong idea over and over doesn't make it true, bub.

-- 
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/  | *\##|
|#/ * |   \#|
|#----|----#|
||    |  * ||
|o *  |    o|
|_____|_____|
|===========|

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


#25714

Fromjlp <jlp@jlp.com>
Date2011-02-05 08:31 +0100
Message-ID<4d4cfcce$0$32450$ba4acef3@reader.news.orange.fr>
In reply to#25516
Le 05/02/2011 07:45, Lawrence D'Oliveiro a écrit :
> In message<iiikcq$rp2$1@news.albasani.net>, Lew wrote:
>
>> Reference to the C++ spec sheds absolutely no light whatsoever on Java.
>
> That’s where the term “virtual” comes from.
>
>>> Like I said, in Java, effectively all methods are virtual.
>>
>> Wrong.  Private and static methods are not virtual.
>
> Without understanding the C++ spec, you cannot understand what “virtual”
> means.
>
from wikipedia : http://en.wikipedia.org/wiki/Virtual_function
so private methods can be virtual

In Java, all non-static methods are by default "virtual functions." Only 
methods marked with the keyword final, which cannot be overridden, along 
with private methods, which are not inherited, are non-virtual.

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


#26010

FromLew <noone@lewscanon.com>
Date2011-02-05 09:08 -0500
Message-ID<iijlkm$a3i$2@news.albasani.net>
In reply to#25714
jlp wrote:
> from wikipedia : http://en.wikipedia.org/wiki/Virtual_function
> so private methods can be virtual

Not in Java, they can't.

> In Java, all non-static methods are by default "virtual functions." Only
> methods marked with the keyword final, which cannot be overridden, along with
> private methods, which are not inherited, are non-virtual.

So you contradict yourself.  Make up your mind.

-- 
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/  | *\##|
|#/ * |   \#|
|#----|----#|
||    |  * ||
|o *  |    o|
|_____|_____|
|===========|

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


#25766

FromArne Vajhøj <arne@vajhoej.dk>
Date2011-02-06 20:44 -0500
Message-ID<4d4f4e85$0$23755$14726298@news.sunsite.dk>
In reply to#25516
On 05-02-2011 15:16, Mike Schilling wrote:
> "Arne Vajhøj" <arne@vajhoej.dk> wrote in message
> news:4d4da3de$0$23764$14726298@news.sunsite.dk...
>> On 04-02-2011 21:27, Mike Schilling wrote:
>>> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in
>>> message news:iiiaia$5t9$1@lust.ihug.co.nz...
>>>> In message <iii9dq$3pr$1@news.eternal-september.org>, Mike Schilling
>>>> wrote:
>>>>
>>>>> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in
>>>>> message
>>>>> news:iii8s4$4tt$1@lust.ihug.co.nz...
>>>>>>
>>>>>> You already have that confusion, when every method declaration in
>>>>>> Java is
>>>>>> effectively virtual, unlike C++.
>>>>>
>>>>> That's not true, you know.
>>>>
>>>> No, I don’t know. Please explain.
>>>
>>> Private methods are not virtual, nor are static methods.
>>
>> Nor final methods.
>
> Yes and no. If a final method overrides a non-final method, it can still
> be called virtually.

True. The final only affects downwards.

Arne

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


#25789

FromLew <noone@lewscanon.com>
Date2011-02-05 09:07 -0500
Message-ID<iijlih$a3i$1@news.albasani.net>
In reply to#25516
Lew wrote:
>> Reference to the C++ spec sheds absolutely no light whatsoever on Java.

Lawrence D'Oliveiro wrote:
> That’s where the term “virtual” comes from.

No, that is completely mistaken.  C++ adopted the term because it used the 
technique.  Smalltalk had it before C++.

>>> Like I said, in Java, effectively all methods are virtual.

Lew wrote:
>> Wrong.  Private and static methods are not virtual.

Lawrence D'Oliveiro wrote:
> Without understanding the C++ spec, you cannot understand what “virtual”
> means.

What a bullshit thing to say.  Surely you aren't serious.  You could, for 
example, understand the Java spec.  Or you could understand the Smalltalk 
spec.  Or you could understand
http://en.wikipedia.org/wiki/Dynamic_dispatch

It remains that in Java, static and private methods are not virtual, a point 
you seem to want to refute by talking about the C++ spec.  That's like trying 
to understand a Porsche by reading a Ford repair manual.

In any event, you're wasting your time trying to refute a point that happens 
to be factual and verifiable.

Without understand what a "virtual" method is, you won't understand the Java spec.

-- 
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/  | *\##|
|#/ * |   \#|
|#----|----#|
||    |  * ||
|o *  |    o|
|_____|_____|
|===========|

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


#25795

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-02-05 16:51 +1300
Message-ID<iiihfu$9pf$1@lust.ihug.co.nz>
In reply to#25516
In message <iiicja$epf$1@news.eternal-september.org>, Mike Schilling wrote:

> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in message
> news:iiiaia$5t9$1@lust.ihug.co.nz...
>
>> In message <iii9dq$3pr$1@news.eternal-september.org>, Mike Schilling
>> wrote:
>>
>>> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in
>>> message news:iii8s4$4tt$1@lust.ihug.co.nz...
>>>>
>>>> You already have that confusion, when every method declaration in Java
>>>> is effectively virtual, unlike C++.
>>>
>>> That's not true, you know.
>>
>> No, I don’t know. Please explain.
> 
> Private methods are not virtual, nor are static methods.

Private methods can still be virtual—see pages 189-190 of the C++ spec for 
an example. And I can’t see any prohibition in section 10.3 (“Virtual 
functions”) against them being static.

Like I said, in Java, effectively all methods are virtual.

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


#25873

FromJoshua Cranmer <Pidgeot18@verizon.invalid>
Date2011-02-04 23:06 -0500
Message-ID<iiiibf$94e$2@news.eternal-september.org>
In reply to#25795
On 02/04/2011 10:51 PM, Lawrence D'Oliveiro wrote:
> In message<iiicja$epf$1@news.eternal-september.org>, Mike Schilling wrote:
>> Private methods are not virtual, nor are static methods.
>
> Private methods can still be virtual—see pages 189-190 of the C++ spec for
> an example. And I can’t see any prohibition in section 10.3 (“Virtual
> functions”) against them being static.

Java private and static methods are not virtual.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

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


#26137

FromLawrence D'Oliveiro <ldo@geek-central.gen.new_zealand>
Date2011-02-05 19:45 +1300
Message-ID<iiirln$fh3$3@lust.ihug.co.nz>
In reply to#25795
In message <iiikcq$rp2$1@news.albasani.net>, Lew wrote:

> Reference to the C++ spec sheds absolutely no light whatsoever on Java.

That’s where the term “virtual” comes from.

>> Like I said, in Java, effectively all methods are virtual.
> 
> Wrong.  Private and static methods are not virtual.

Without understanding the C++ spec, you cannot understand what “virtual” 
means.

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


#26160

FromJoshua Cranmer <Pidgeot18@verizon.invalid>
Date2011-02-05 10:32 -0500
Message-ID<iijqj4$7a4$1@news.eternal-september.org>
In reply to#26137
On 02/05/2011 01:45 AM, Lawrence D'Oliveiro wrote:
> Without understanding the C++ spec, you cannot understand what “virtual”
> means.

That is very arrogant of you. Especially since the JLS only uses the 
word "virtual" (outside of the phrase "virtual machine") in §15:

The invocation mode, computed as follows:

     If the compile-time declaration has the static modifier, then the 
invocation mode is static.
     Otherwise, if the compile-time declaration has the private 
modifier, then the invocation mode is nonvirtual.
     Otherwise, if the part of the method invocation before the left 
parenthesis is of the form super . Identifier or of the form 
ClassName.super.Identifier then the invocation mode is super.
     Otherwise, if the compile-time declaration is in an interface, then 
the invocation mode is interface.
     Otherwise, the invocation mode is virtual.

[ ... ]

If class S contains a declaration for a non-abstract method named m with 
the same descriptor (same number of parameters, the same parameter 
types, and the same return type) required by the method invocation as 
determined at compile time (§15.12.3), then:

     If the invocation mode is super or interface, then this is the 
method to be invoked, and the procedure terminates.
     If the invocation mode is virtual, and the declaration in S 
overrides (§8.4.8.1) X.m, then the method declared in S is the method to 
be invoked, and the procedure terminates.


I might add that, in the JLS usage, private methods cannot be virtual 
since any method with a private modifier is either static or nonvirtual.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

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


#26176

FromLew <noone@lewscanon.com>
Date2011-02-04 23:40 -0500
Message-ID<iiikcq$rp2$1@news.albasani.net>
In reply to#25795
Lawrence D'Oliveiro wrote:
>>>>> You already have that confusion, when every method declaration in Java
>>>>> is effectively virtual, unlike C++.

Mike Schilling wrote:
>>>> That's not true, you know.

Lawrence D'Oliveiro wrote:
>>> No, I don’t know. Please explain.

Mike Schilling wrote:
>> Private methods are not virtual, nor are static methods.

Lawrence D'Oliveiro wrote:
> Private methods can still be virtual—see pages 189-190 of the C++ spec for
> an example. And I can’t see any prohibition in section 10.3 (“Virtual
> functions”) against them being static.

Reference to the C++ spec sheds absolutely no light whatsoever on Java.

> Like I said, in Java, effectively all methods are virtual.

Wrong.  Private and static methods are not virtual.

-- 
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/  | *\##|
|#/ * |   \#|
|#----|----#|
||    |  * ||
|o *  |    o|
|_____|_____|
|===========|

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


#26188

FromArne Vajhøj <arne@vajhoej.dk>
Date2011-02-07 19:15 -0500
Message-ID<4d508b0a$0$23762$14726298@news.sunsite.dk>
In reply to#25795
On 04-02-2011 22:51, Lawrence D'Oliveiro wrote:
> In message<iiicja$epf$1@news.eternal-september.org>, Mike Schilling wrote:
>
>> "Lawrence D'Oliveiro"<ldo@geek-central.gen.new_zealand>  wrote in message
>> news:iiiaia$5t9$1@lust.ihug.co.nz...
>>
>>> In message<iii9dq$3pr$1@news.eternal-september.org>, Mike Schilling
>>> wrote:
>>>
>>>> "Lawrence D'Oliveiro"<ldo@geek-central.gen.new_zealand>  wrote in
>>>> message news:iii8s4$4tt$1@lust.ihug.co.nz...
>>>>>
>>>>> You already have that confusion, when every method declaration in Java
>>>>> is effectively virtual, unlike C++.
>>>>
>>>> That's not true, you know.
>>>
>>> No, I don’t know. Please explain.
>>
>> Private methods are not virtual, nor are static methods.
>
> Private methods can still be virtual—see pages 189-190 of the C++ spec for
> an example. And I can’t see any prohibition in section 10.3 (“Virtual
> functions”) against them being static.
>
> Like I said, in Java, effectively all methods are virtual.

No.

And I can't understand why you think the C++ spec applies
to Java.

Especially since the Java spec explicit says otherwise.

Arne

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


#26145

FromKevin McMurtrie <mcmurtrie@pixelmemory.us>
Date2011-02-04 21:31 -0800
Message-ID<4d4ce09c$0$22122$742ec2ed@news.sonic.net>
In reply to#25516
In article <iiicja$epf$1@news.eternal-september.org>,
 "Mike Schilling" <mscottschilling@hotmail.com> wrote:

> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in message 
> news:iiiaia$5t9$1@lust.ihug.co.nz...
> > In message <iii9dq$3pr$1@news.eternal-september.org>, Mike Schilling 
> > wrote:
> >
> >> "Lawrence D'Oliveiro" <ldo@geek-central.gen.new_zealand> wrote in message
> >> news:iii8s4$4tt$1@lust.ihug.co.nz...
> >>>
> >>> You already have that confusion, when every method declaration in Java 
> >>> is
> >>> effectively virtual, unlike C++.
> >>
> >> That's not true, you know.
> >
> > No, I don’t know. Please explain.
> 
> Private methods are not virtual, nor are static methods. 

And HotSpot may change methods between static and virtual at runtime 
too.  It's an expensive optimization but it's how Java sometimes 
achieves performance comparable to C.  Without it, it would never come 
close.
-- 
I will not see posts or email from Google because I must filter them as spam

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


#26146

FromLew <noone@lewscanon.com>
Date2011-02-05 01:25 -0500
Message-ID<iiiqgj$46f$1@news.albasani.net>
In reply to#26145
Kevin McMurtrie wrote:
> And HotSpot may change methods between static and virtual at runtime
> too.  It's an expensive optimization but it's how Java sometimes
> achieves performance comparable to C.  Without it, it would never come
> close.

I get what you mean, but I'm pretty sure "static" is the wrong word there. 
"static" means "belongs to the class, not an instance".  Virtual methods 
always belong to an instance, so they can never be static.

-- 
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/  | *\##|
|#/ * |   \#|
|#----|----#|
||    |  * ||
|o *  |    o|
|_____|_____|
|===========|

[toc] | [prev] | [standalone]


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


csiph-web