* automatic casting
@ 2004-08-31 13:01 kartick Vaddadi
2004-08-31 13:03 ` Paolo Bonzini
2004-08-31 14:41 ` Diego Novillo
0 siblings, 2 replies; 4+ messages in thread
From: kartick Vaddadi @ 2004-08-31 13:01 UTC (permalink / raw)
To: gcc
in code such as this:
if (o instanceof Dog)
{
Dog d = (Dog)o;
d.bark();
. . .
}
why not eliminate the requirement to cast, since the
instanceof ensures that the object is of the right
type;i.e., u should be able to write:
if(o instanceof Dog)
{
o.bark();
. . .
}
what do u think?
-kartick
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: automatic casting
2004-08-31 13:01 automatic casting kartick Vaddadi
@ 2004-08-31 13:03 ` Paolo Bonzini
2004-08-31 14:41 ` Diego Novillo
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2004-08-31 13:03 UTC (permalink / raw)
To: kartick Vaddadi, GCC Development
> why not eliminate the requirement to cast, since the
> instanceof ensures that the object is of the right
You should ask Sun about this, not the GCC community; there are no GNU
extensions to the Java language. Anyway the answer is probably going to
be that while this case is obvious, there are going to be more and more
complicated cases that the compiler won't possibly figure out.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: automatic casting
2004-08-31 13:01 automatic casting kartick Vaddadi
2004-08-31 13:03 ` Paolo Bonzini
@ 2004-08-31 14:41 ` Diego Novillo
2004-08-31 20:04 ` Tom Tromey
1 sibling, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2004-08-31 14:41 UTC (permalink / raw)
To: kartick Vaddadi; +Cc: gcc
On Tue, 2004-08-31 at 08:49, kartick Vaddadi wrote:
> if(o instanceof Dog)
> {
> o.bark();
> . . .
> }
>
I think this is the same issue reported in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15525
If so, there may be a patch coming down the road to support this.
Diego.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: automatic casting
2004-08-31 14:41 ` Diego Novillo
@ 2004-08-31 20:04 ` Tom Tromey
0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2004-08-31 20:04 UTC (permalink / raw)
To: Diego Novillo; +Cc: gcc
>>>>> "Diego" == Diego Novillo <dnovillo@redhat.com> writes:
Diego> On Tue, 2004-08-31 at 08:49, kartick Vaddadi wrote:
>> if(o instanceof Dog)
>> {
>> o.bark();
>> . . .
>> }
Diego> I think this is the same issue reported in
Diego> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15525
Diego> If so, there may be a patch coming down the road to support this.
This is related. The original poster wanted a language extension. I
don't think we'll do this; a language extension would need a strong
justification, and this particular extension would mean mixing flow
control with semantic analysis, which would be pretty ugly to
implement.
The PR is about removing redundant casts from the generated code.
I'll upload my patch into the PR soon. It works ok, but as I recall
it needs VRP to remove everything. When I upload it I'll put the info
in the PR.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-08-31 19:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-31 13:01 automatic casting kartick Vaddadi
2004-08-31 13:03 ` Paolo Bonzini
2004-08-31 14:41 ` Diego Novillo
2004-08-31 20:04 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).