Re: Java needs "goto" (was Re: hi)
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 5 Feb 2007 17:52:04 -0000
Randolf Richardson wrote:
This typically occurs because the reserved word "goto" isn't
implemented. There are situations where "goto" would be very useful, such
as:
0. An alternative to "break label" since label is currently limited in
where it can be located (such code could be easier to read)
I'm not in the "GOTO is intrinsically evil" camp -- I think it has its uses,
and (if used with discretion, which is the only way that anyone /does/ use goto
these days), can help keep code clean. Mind you, a lot of the reasonable uses
for goto are replaced in Java by try/finally statements; so I'm not sure that
it would actually pay for itself.
But the labelled-break thing is, IMO, even worse than goto could possibly be --
it always seems to make the code confusing. Fortunately, it is hardly ever
used. To be honest, I don't know whether the few times I /have/ seen it used
are confusing because the programmer (having labelled break available) didn't
feel the need to find a clearer structure, or because the underlying task logic
itself was inherently confusing, and a labelled break was the best available
way to express it.
1. The ability to share code between methods within a class, which all
end with the same functionality (this could be more efficient than calling
another method; javac would need to generate errors such as attempts to
access variables that belong to different methods, return type mismatches,
etc.)
I think that's technically infeasible given anything like current JVM
implementation technologies.
-- chris
.
- References:
- Java needs "goto" (was Re: hi)
- From: Randolf Richardson
- Java needs "goto" (was Re: hi)
- Prev by Date: Re: new java group
- Next by Date: Re: Is there any tool to describe program algorithm in flowchart and generate code from the chart?
- Previous by thread: Re: Java needs "goto" (was Re: hi)
- Next by thread: Re: Json Parser anyone?
- Index(es):
Relevant Pages
|