Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19275 > unrolled thread
| Started by | Wojtek <nowhere@a.com> |
|---|---|
| First post | 2012-10-12 22:54 -0700 |
| Last post | 2012-10-23 00:38 +0200 |
| Articles | 20 on this page of 67 — 19 participants |
Back to article view | Back to comp.lang.java.programmer
Assigning void Wojtek <nowhere@a.com> - 2012-10-12 22:54 -0700
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-12 23:27 -0700
Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-13 12:35 -0700
Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-13 09:26 -0400
Re: Assigning void Donkey Hottie <donkey@fredriksson.dy.fi> - 2012-10-13 17:06 +0300
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 10:34 -0400
Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-13 22:33 +0200
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 17:34 -0400
Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-13 17:45 -0400
Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-13 21:35 -0400
Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-16 00:16 +0200
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 11:59 -0400
Re: Assigning void glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-10-13 17:05 +0000
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 14:26 -0400
Re: Assigning void markspace <-@.> - 2012-10-13 11:51 -0700
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 15:08 -0400
Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-13 12:28 -0700
Re: Assigning void markspace <-@.> - 2012-10-13 12:42 -0700
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 12:54 -0700
OT - Trolling Wojtek <nowhere@a.com> - 2012-10-13 14:16 -0700
Re: OT - Trolling Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 18:09 -0400
Re: OT - Trolling Gene Wirchenko <genew@ocis.net> - 2012-10-14 18:47 -0700
Re: Assigning void Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-13 20:28 +0000
Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-13 13:31 -0700
Re: Assigning void Joerg Meier <joergmmeier@arcor.de> - 2012-10-20 18:00 +0200
Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-20 09:56 -0700
Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-21 13:24 +0200
Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-21 10:23 -0700
Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 00:13 +0200
Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-21 16:25 -0700
Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 08:43 +0200
Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 10:18 +0200
Re: Assigning void Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-22 08:14 -0700
Re: Assigning void glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-10-21 19:45 +0000
Re: Assigning void "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-10-22 00:14 +0200
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 12:44 -0700
Re: Assigning void Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-10-15 14:38 +0300
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-15 09:11 -0700
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 15:03 -0400
Re: Assigning void glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-10-13 20:21 +0000
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 12:38 -0700
Re: Assigning void markspace <-@.> - 2012-10-13 12:49 -0700
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-13 13:03 -0700
Re: Assigning void Robert Klemme <shortcutter@googlemail.com> - 2012-10-14 14:09 +0200
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-14 11:31 -0700
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 19:55 -0400
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 20:25 -0400
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-13 21:01 -0400
Re: Assigning void Gene Wirchenko <genew@ocis.net> - 2012-10-14 18:42 -0700
Re: Assigning void Roedy Green <see_website@mindprod.com.invalid> - 2012-10-14 00:51 -0700
Re: Assigning void Jeff Higgins <jeff@invalid.invalid> - 2012-10-14 10:40 -0400
Re: Assigning void Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-21 01:24 +0200
Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-21 14:52 -0700
Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-21 20:13 -0400
Re: Assigning void Wojtek <nowhere@a.com> - 2012-10-21 20:20 -0700
Re: Assigning void Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-22 11:12 +0200
Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-24 22:03 +0200
Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-24 17:47 -0400
Re: Assigning void Wanja Gayk <brixomatic@yahoo.com> - 2012-10-25 01:02 +0200
Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-24 20:21 -0400
Re: Assigning void Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-25 20:04 +0000
(OT) Re: Assigning void Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-25 16:31 -0400
Re: (OT) Re: Assigning void Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-25 20:44 +0000
Re: Assigning void Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-10-25 07:25 -0300
Re: Assigning void Lew <lewbloch@gmail.com> - 2012-10-25 11:12 -0700
Re: Assigning void Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-22 11:01 +0200
Re: Assigning void Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-10-23 00:38 +0200
Page 1 of 4 [1] 2 3 4 Next page →
| From | Wojtek <nowhere@a.com> |
|---|---|
| Date | 2012-10-12 22:54 -0700 |
| Subject | Assigning void |
| Message-ID | <mn.655e7dca256cdfb1.70216@a.com> |
I can legally do the following: if (server.getConnectionType() == ConnectionType.ACTIVE) ftp.enterLocalActiveMode(); else ftp.enterLocalPassiveMode(); but I want to do: (server.getConnectionType() == ConnectionType.ACTIVE) ? ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); However the compiler insists that I must have an assignment even though both ftp methods return void. I would think that the compiler would be smart enough to realize that nothing CAN be returned. Oh yes, I am using Eclipse with Java 7 Thoughts? I mean other than stylistic comments... -- Wojtek :-)
[toc] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-10-12 23:27 -0700 |
| Message-ID | <793cfc49-67ae-4fcf-8176-d970eb88f895@googlegroups.com> |
| In reply to | #19275 |
Wojtek wrote: > I can legally do the following: > > if (server.getConnectionType() == ConnectionType.ACTIVE) > ftp.enterLocalActiveMode(); > else > ftp.enterLocalPassiveMode(); > > but I want to do: > > (server.getConnectionType() == ConnectionType.ACTIVE) ? > ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); > > However the compiler insists that I must have an assignment even though > both ftp methods return void. I would think that the compiler would be > smart enough to realize that nothing CAN be returned. > > Oh yes, I am using Eclipse with Java 7 > > Thoughts? I mean other than stylistic comments... The compiler is smart enough to realize that nothing can be returned. It's also smart enough to realize that standalone expressions, such as this one or a lone 'x', are not legal. http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.8 and the rest of Chapter 14. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Wojtek <nowhere@a.com> |
|---|---|
| Date | 2012-10-13 12:35 -0700 |
| Message-ID | <mn.6af37dca563f84fe.70216@a.com> |
| In reply to | #19276 |
Lew wrote : > Wojtek wrote: >> I can legally do the following: >> >> if (server.getConnectionType() == ConnectionType.ACTIVE) >> ftp.enterLocalActiveMode(); >> else >> ftp.enterLocalPassiveMode(); >> >> but I want to do: >> >> (server.getConnectionType() == ConnectionType.ACTIVE) ? >> ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); >> >> However the compiler insists that I must have an assignment even though >> both ftp methods return void. I would think that the compiler would be >> smart enough to realize that nothing CAN be returned. >> >> Oh yes, I am using Eclipse with Java 7 >> >> Thoughts? I mean other than stylistic comments... > > The compiler is smart enough to realize that nothing can be returned. > > It's also smart enough to realize that standalone expressions, such > as this one or a lone 'x', are not legal. > > http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.8 > and the rest of Chapter 14. I had not considered it to be an expression, though thinking about it now, it would have to be. But it is kind of special in that any assignment is conditional, so it could have special rules. -- Wojtek :-)
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2012-10-13 09:26 -0400 |
| Message-ID | <k5bq6t$rl6$2@dont-email.me> |
| In reply to | #19275 |
On 10/13/2012 1:54 AM, Wojtek wrote: > I can legally do the following: > > if (server.getConnectionType() == ConnectionType.ACTIVE) > ftp.enterLocalActiveMode(); > else > ftp.enterLocalPassiveMode(); > > but I want to do: > > (server.getConnectionType() == ConnectionType.ACTIVE) ? > ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); > > However the compiler insists that I must have an assignment even though > both ftp methods return void. I would think that the compiler would be > smart enough to realize that nothing CAN be returned. > > Oh yes, I am using Eclipse with Java 7 > > Thoughts? I mean other than stylistic comments... http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.25 ... with special attention to the second BOLDFACE sentence. -- Eric Sosman esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Donkey Hottie <donkey@fredriksson.dy.fi> |
|---|---|
| Date | 2012-10-13 17:06 +0300 |
| Message-ID | <q49ok9-rrp.ln1@tempest.fredriksson.dy.fi> |
| In reply to | #19275 |
13.10.2012 08:54, Wojtek kirjoitti: > I can legally do the following: > > if (server.getConnectionType() == ConnectionType.ACTIVE) > ftp.enterLocalActiveMode(); > else > ftp.enterLocalPassiveMode(); > > but I want to do: > > (server.getConnectionType() == ConnectionType.ACTIVE) ? > ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); > > However the compiler insists that I must have an assignment even though > both ftp methods return void. I would think that the compiler would be > smart enough to realize that nothing CAN be returned. > > Oh yes, I am using Eclipse with Java 7 > > Thoughts? I mean other than stylistic comments... > Why do you want to use an assignment statement without need or means to assign anything to anywhere? What's the rationale? -- You can rent this space for only $5 a week.
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-10-13 10:34 -0400 |
| Message-ID | <k5btq4$i7j$1@dont-email.me> |
| In reply to | #19279 |
On 10/13/2012 10:06 AM, Donkey Hottie wrote: > 13.10.2012 08:54, Wojtek kirjoitti: >> I can legally do the following: >> >> if (server.getConnectionType() == ConnectionType.ACTIVE) >> ftp.enterLocalActiveMode(); >> else >> ftp.enterLocalPassiveMode(); >> >> but I want to do: >> >> (server.getConnectionType() == ConnectionType.ACTIVE) ? >> ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); >> >> However the compiler insists that I must have an assignment even though >> both ftp methods return void. I would think that the compiler would be >> smart enough to realize that nothing CAN be returned. >> >> Oh yes, I am using Eclipse with Java 7 >> >> Thoughts? I mean other than stylistic comments... >> > > Why do you want to use an assignment statement without need or means to > assign anything to anywhere? I'm guessing he doesn’t. > What's the rationale? I'm guessing his eye beholds beauty in the latter.
[toc] | [prev] | [next] | [standalone]
| From | Wanja Gayk <brixomatic@yahoo.com> |
|---|---|
| Date | 2012-10-13 22:33 +0200 |
| Message-ID | <MPG.2ae3c02687218ddc989738@202.177.16.121> |
| In reply to | #19279 |
In article <q49ok9-rrp.ln1@tempest.fredriksson.dy.fi>, donkey@fredriksson.dy.fi says... > > if (server.getConnectionType() == ConnectionType.ACTIVE) > > ftp.enterLocalActiveMode(); > > else > > ftp.enterLocalPassiveMode(); > > > > but I want to do: > > > > (server.getConnectionType() == ConnectionType.ACTIVE) ? > > ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); > > Why do you want to use an assignment statement without need or means to > assign anything to anywhere? What's the rationale? I think the author is questioning, why this statement is only usable as an assignment statement. Yes you don't it, as you could refactor the code like this: ftp.enterMode( server.getConnectionType() == ACTIVE ? Mode.LOCAL_ACTIVE : Mode.LOCAL_PASSIVE ); But still I fancy the idea to be able to write: purse.isEmpty() ? goHome() : goToTheMovies(); as a shorthand for: if (purse.isEmpty()) goHome(); else goToTheMovies(); What would be wrong about that? Kind Regards, Wanja -- ..Alesi's problem was that the back of the car was jumping up and down dangerously - and I can assure you from having been teammate to Jean Alesi and knowing what kind of cars that he can pull up with, when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer] --- news://freenews.netfront.net/ - complaints: news@netfront.net ---
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-10-13 17:34 -0400 |
| Message-ID | <k5cmei$cle$1@dont-email.me> |
| In reply to | #19305 |
On 10/13/2012 04:33 PM, Wanja Gayk wrote: > In article<q49ok9-rrp.ln1@tempest.fredriksson.dy.fi>, > donkey@fredriksson.dy.fi says... > >>> if (server.getConnectionType() == ConnectionType.ACTIVE) >>> ftp.enterLocalActiveMode(); >>> else >>> ftp.enterLocalPassiveMode(); >>> >>> but I want to do: >>> >>> (server.getConnectionType() == ConnectionType.ACTIVE) ? >>> ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); >> >> Why do you want to use an assignment statement without need or means to >> assign anything to anywhere? What's the rationale? > > I think the author is questioning, why this statement is only usable as > an assignment statement. > > Yes you don't it, as you could refactor the code like this: > > ftp.enterMode( > server.getConnectionType() == ACTIVE ? Mode.LOCAL_ACTIVE > : Mode.LOCAL_PASSIVE > ); > > But still I fancy the idea to be able to write: > > purse.isEmpty() ? goHome() : goToTheMovies(); > as a shorthand for: > if (purse.isEmpty()) goHome(); else goToTheMovies(); > > What would be wrong about that? > According to others in parallel threads it's all wrong. I agree it would be pretty.
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2012-10-13 17:45 -0400 |
| Message-ID | <k5cndu$i9t$1@dont-email.me> |
| In reply to | #19305 |
On 10/13/2012 4:33 PM, Wanja Gayk wrote:
>[...]
> But still I fancy the idea to be able to write:
>
> purse.isEmpty() ? goHome() : goToTheMovies();
> as a shorthand for:
> if (purse.isEmpty()) goHome(); else goToTheMovies();
>
> What would be wrong about that?
(purse.isEmpty()
? new Runnable() {
@Override
public void run() {
goHome();
}
}
: new Runnable() {
@Override
public void run() {
goToTheMovies();
}
}
).doIt();
Problem solved!
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2012-10-13 21:35 -0400 |
| Message-ID | <k5d4sh$qbv$1@dont-email.me> |
| In reply to | #19311 |
On 10/13/2012 5:45 PM, Eric Sosman wrote:
> On 10/13/2012 4:33 PM, Wanja Gayk wrote:
>> [...]
>> But still I fancy the idea to be able to write:
>>
>> purse.isEmpty() ? goHome() : goToTheMovies();
>> as a shorthand for:
>> if (purse.isEmpty()) goHome(); else goToTheMovies();
>>
>> What would be wrong about that?
>
> (purse.isEmpty()
> ? new Runnable() {
> @Override
> public void run() {
> goHome();
> }
> }
> : new Runnable() {
> @Override
> public void run() {
> goToTheMovies();
> }
> }
> ).doIt();
>
> Problem solved!
... once the method name in the final line is changed from
`doIt' to `run'. >Sigh< The perils of making "clarifying edits"
without similar attention to proofreading ...
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Wanja Gayk <brixomatic@yahoo.com> |
|---|---|
| Date | 2012-10-16 00:16 +0200 |
| Message-ID | <MPG.2ae6a99e4293e23998973a@202.177.16.121> |
| In reply to | #19311 |
In article <k5cndu$i9t$1@dont-email.me>, esosman@comcast-dot-net.invalid
says...
> On 10/13/2012 4:33 PM, Wanja Gayk wrote:
> >[...]
> > But still I fancy the idea to be able to write:
> >
> > purse.isEmpty() ? goHome() : goToTheMovies();
> > as a shorthand for:
> > if (purse.isEmpty()) goHome(); else goToTheMovies();
> >
> > What would be wrong about that?
>
> (purse.isEmpty()
> ? new Runnable() {
> @Override
> public void run() {
> goHome();
> }
> }
> : new Runnable() {
> @Override
> public void run() {
> goToTheMovies();
> }
> }
> ).doIt();
>
> Problem solved!
Yes, Problem solved. But who wipes the vomit from the floor?
Kind regards,
Wanja
--
..Alesi's problem was that the back of the car was jumping up and down
dangerously - and I can assure you from having been teammate to
Jean Alesi and knowing what kind of cars that he can pull up with,
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-10-13 11:59 -0400 |
| Message-ID | <k5c2q6$hio$1@dont-email.me> |
| In reply to | #19275 |
On 10/13/2012 01:54 AM, Wojtek wrote: > I can legally do the following: > > if (server.getConnectionType() == ConnectionType.ACTIVE) > ftp.enterLocalActiveMode(); > else > ftp.enterLocalPassiveMode(); > > but I want to do: > > (server.getConnectionType() == ConnectionType.ACTIVE) ? > ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); > > However the compiler insists that I must have an assignment even though > both ftp methods return void. I would think that the compiler would be > smart enough to realize that nothing CAN be returned. > > Oh yes, I am using Eclipse with Java 7 > > Thoughts? I mean other than stylistic comments... > Others have pointed you to the specification. I don't know why it can't be a shorthand if-then-else statement too.
[toc] | [prev] | [next] | [standalone]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Date | 2012-10-13 17:05 +0000 |
| Message-ID | <k5c6vs$p9v$1@speranza.aioe.org> |
| In reply to | #19281 |
Jeff Higgins <jeff@invalid.invalid> wrote: (snip) >> (server.getConnectionType() == ConnectionType.ACTIVE) ? >> ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); (snip) > Others have pointed you to the specification. > I don't know why it can't be a shorthand if-then-else statement too. Java isn't C. Java allows for method calls that return a value to ignore the return value, but other expressions that don't use the value seem not to be allowed. 2+2; is legal C, but not Java. -- glen
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-10-13 14:26 -0400 |
| Message-ID | <k5cbcn$9dl$1@dont-email.me> |
| In reply to | #19284 |
On 10/13/2012 01:05 PM, glen herrmannsfeldt wrote: > Jeff Higgins<jeff@invalid.invalid> wrote: > > (snip) > >>> (server.getConnectionType() == ConnectionType.ACTIVE) ? >>> ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); > > (snip) > >> Others have pointed you to the specification. >> I don't know why it can't be a shorthand if-then-else statement too. > > Java isn't C. > > Java allows for method calls that return a value to ignore the > return value, but other expressions that don't use the value > seem not to be allowed. > > 2+2; > > is legal C, but not Java. > C has its Rationale. Java seems not to have a separate formal one. 6.5.15 of the C Rationale only states the construct is allowed and not why. 15.25 of the Java Spec. only states the construct is disallowed and not why. Does it sound childish to ask why?
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-10-13 11:51 -0700 |
| Message-ID | <k5cd80$k8p$1@dont-email.me> |
| In reply to | #19285 |
On 10/12/2012 10:54 PM, Wojtek wrote:
> both ftp methods return void. I would think that the compiler would
> be smart enough to realize that nothing CAN be returned.
On 10/13/2012 11:26 AM, Jeff Higgins wrote:
> Does it sound childish to ask why?
The way the OP puts it, yes, it comes across as a bit childish. The OP
didn't ask "why," he asked for "thoughts." My thought is "read the JLS."
I realize *you* asked why, but in the vein of the OP's premise, I feel
"read the spec" is a valid answer. "Why" requires reading someone's
mind, and time travel. Since those are obviously impossible, the result
borders on trolling.
I'd guess that the original intent and the current thinking is that Java
should be "easy to read" and that shortening branch flow to a single
character pushes somebody's Perl buttons, but that's a total guess.
What about this:
(some large expression || some other large expression )
? {
Statement;
Statement;
Statement;
} : {
Statement;
Statement;
Statement;
}
? Do we really want to go there?
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-10-13 15:08 -0400 |
| Message-ID | <k5cdsr$o7v$1@dont-email.me> |
| In reply to | #19286 |
On 10/13/2012 02:51 PM, markspace wrote:
> On 10/12/2012 10:54 PM, Wojtek wrote:
>> both ftp methods return void. I would think that the compiler would
>> be smart enough to realize that nothing CAN be returned.
>
>
> On 10/13/2012 11:26 AM, Jeff Higgins wrote:
>> Does it sound childish to ask why?
>
>
> The way the OP puts it, yes, it comes across as a bit childish. The OP
> didn't ask "why," he asked for "thoughts." My thought is "read the JLS."
>
> I realize *you* asked why, but in the vein of the OP's premise, I feel
> "read the spec" is a valid answer. "Why" requires reading someone's
> mind, and time travel. Since those are obviously impossible, the result
> borders on trolling.
>
> I'd guess that the original intent and the current thinking is that Java
> should be "easy to read" and that shortening branch flow to a single
> character pushes somebody's Perl buttons, but that's a total guess.
>
> What about this:
>
> (some large expression || some other large expression )
> ? {
> Statement;
> Statement;
> Statement;
> } : {
> Statement;
> Statement;
> Statement;
> }
>
> ? Do we really want to go there?
I suppose it would be allowed in my
boolean expression ? block : block ;
and would probably be ugly per your example.
But I think
(server.getConnectionType() == ConnectionType.ACTIVE) ?
ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode();
would be pretty.
[toc] | [prev] | [next] | [standalone]
| From | Wojtek <nowhere@a.com> |
|---|---|
| Date | 2012-10-13 12:28 -0700 |
| Message-ID | <mn.6aec7dcaffbb07c0.70216@a.com> |
| In reply to | #19286 |
markspace wrote :
> On 10/12/2012 10:54 PM, Wojtek wrote:
>> both ftp methods return void. I would think that the compiler would
>> be smart enough to realize that nothing CAN be returned.
>
>
> On 10/13/2012 11:26 AM, Jeff Higgins wrote:
>> Does it sound childish to ask why?
>
>
> The way the OP puts it, yes, it comes across as a bit childish. The OP
> didn't ask "why," he asked for "thoughts." My thought is "read the JLS."
Hmm, I wasn't questioning the compiler as I would hope it follows the
JLS.
Yes, I have a C background, and I have used this expression many times,
and indeed I have nested it several layers deep, since it made most
sense (to me) to do so.
> I realize *you* asked why, but in the vein of the OP's premise, I feel "read
> the spec" is a valid answer. "Why" requires reading someone's mind, and time
> travel. Since those are obviously impossible, the result borders on
> trolling.
So questioning a design decision and trying to understand its rational
is trolling? Really?
> I'd guess that the original intent and the current thinking is that Java
> should be "easy to read" and that shortening branch flow to a single
> character pushes somebody's Perl buttons, but that's a total guess.
There are many ways and many people who try to write code which is easy
to read. Anyone can write obfuscated code, but seasoned coders tend to
try to simplify where possible, not use clever tricks, at least IMHO.
> What about this:
>
> (some large expression || some other large expression )
> ? {
> Statement;
> Statement;
> Statement;
> } : {
> Statement;
> Statement;
> Statement;
> }
>
Interesting. I had not followed the idea that far. Though in common use
it really just replaces a succinct if/else construct.
--
Wojtek :-)
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-10-13 12:42 -0700 |
| Message-ID | <k5cg71$6j7$1@dont-email.me> |
| In reply to | #19290 |
On 10/13/2012 12:28 PM, Wojtek wrote: > So questioning a design decision and trying to understand its rational > is trolling? Really? Yup, because there's no way anyone on this list could possibly answer that question. You might try asking some of the language conferences or at JavaOne. They might be able to tell you, or at least give you a rational. All I can personally say, and I'm pretty sure all anyone here can say, is "Java is easy to read" is a goal, and allowing inline conditional is seen as detrimental to that goal. Maybe.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-10-13 12:54 -0700 |
| Message-ID | <ac913d18-3fef-4a5e-962b-cca10713043e@googlegroups.com> |
| In reply to | #19293 |
markspace wrote: > Wojtek wrote: >> So questioning a design decision and trying to understand its rational[e] >> is trolling? Really? > > Yup, because there's no way anyone on this list could possibly answer > that question. You might try asking some of the language conferences or > at JavaOne. They might be able to tell you, or at least give you a > rational[e]. > > All I can personally say, and I'm pretty sure all anyone here can say, Nope. I said something different, for example. > is "Java is easy to read" is a goal, and allowing inline conditional is > seen as detrimental to that goal. Maybe. I'm afraid I disagree with markspace here. First of all, asking unanswerable questions is not /per se/ trolling. Second, there is much one can say about the rationale for Java. The Founding Coders have written a lot on the ideas behind Java, so we aren't reasoning in a vacuum. Furthermore, the rationale is deduceable from the JLS. Or a rationale is, in any event. It is straightforward to determine why '?:' cannot be a statement from the cited JLS references already. It is clearly part of the rationale of Java that not everything that can be done should be. Java prohibits standalone expressions as statements, unlike C. It's such a fundamental and basic and foundational difference between the languages that I rarely hear anyone question it. "So Java prohibits standalone expressions as statements. Big deal." Fine. Clearly it's part of the rationale of Java that a statement, to be a statement and not just an expression, must effect something. What does 'x? 4 : 5' effect? '?:' is placed in the operators table. Ergo, the rationale not to allow standalone ternary is the rationale not to allow standalone operators generally. Q.E.D. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Wojtek <nowhere@a.com> |
|---|---|
| Date | 2012-10-13 14:16 -0700 |
| Subject | OT - Trolling |
| Message-ID | <mn.6b587dcade27aa1a.70216@a.com> |
| In reply to | #19297 |
Lew wrote : > First of all, asking unanswerable > questions is not /per se/ trolling. I have always considered "trolling" to be making an obnoxious post which is designed to inflame someone into making a contradictory post. Hopefully many someones. Asking a "quiet" question which may/may not be answerable is hardly trolling. Or, I am not trying to kick the cat, just tickle it a little. -- Wojtek :-)
[toc] | [prev] | [next] | [standalone]
Page 1 of 4 [1] 2 3 4 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web