| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#21
| |||
| |||
| Tom Anderson wrote: > This: > > int place ; > while ((place = s.indexOf(x)) >= 0 ) ... > > Can be written: > > for (int place; (place = s.indexOf(x)) >= 0 ...Or for (int place = s.indexOf(x); place >= 0; place = s.indexOf(x)) Which isn't bad except for the redunancy in the first and third clauses. |
|
#22
| |||
| |||
| On Wed, 27 Aug 2008 07:48:26 -0700, Daniel Pitts <newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly quoted someone who said : >void myMethod() { > doSomething(); > { > int foo = 10; > while (foo < 100) { > foo = nextFoo(foo); > } > // foo is not in scope here. > doSomethingElse(); >} The problem you need an ugly extra pair of {}, which even in your case failed to balance. Figuring out nesting and fixing broken nesting is by far the syntax feature of Java what wastes the most of my time and the one that I find hardest just to eyeball. I suggest some ways out in my Scid project. See http://mindprod.com/project/scid.html -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com |
|
#23
| |||
| |||
| On Wed, 27 Aug 2008 12:39:23 +0100, Tom Anderson <twic@urchin.earth.li> wrote, quoted or indirectly quoted someone who said : >int x = (int y = 1) + 1; > >Isn't legal. This: Why not? I am not asking about the language as defined now, but what the language designers might have been thinking when they concocted the syntax. -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com |
|
#24
| |||
| |||
| Roedy Green wrote: > On Wed, 27 Aug 2008 12:39:23 +0100, Tom Anderson > <twic@urchin.earth.li> wrote, quoted or indirectly quoted someone who > said : > >> int x = (int y = 1) + 1; >> >> Isn't legal. This: > > Why not? I am not asking about the language as defined now, but what > the language designers might have been thinking when they concocted > the syntax. They might have considered it and asked "Why on earth would anyone want to write something like that?" |
|
#25
| |||
| |||
| Roedy Green <see_website@mindprod.com.invalid> wrote: > Figuring out nesting and fixing broken nesting is > by far the syntax feature of Java what wastes the > most of my time and the one that I find hardest > just to eyeball. What editor do you use? Most editors designed for coding should have a feature "find matching paranthese/brace/bracket/...". In vi, it's "%". I've seen it in ultraedit as well (but don't remember the keyboard shortcut) and I'd be surprised, if eclipse and netbeans didn't have such a feature. > I suggest some ways out in my Scid project. See > http://mindprod.com/project/scid.html &%$/&%$&/Webwasher seems to have decided that your page belongs to categories: (Politics, Extreme). (Just for your information. I've got my ways to still view it, though less convenient) |
|
#26
| |||
| |||
| Andreas Leitgeb wrote: > Roedy Green <see_website@mindprod.com.invalid> wrote: >> Figuring out nesting and fixing broken nesting is >> by far the syntax feature of Java what wastes the >> most of my time and the one that I find hardest >> just to eyeball. > > What editor do you use? Most editors designed > for coding should have a feature "find matching > paranthese/brace/bracket/...". > In vi, it's "%". I've seen it in ultraedit as well > (but don't remember the keyboard shortcut) and > I'd be surprised, if eclipse and netbeans didn't > have such a feature. IntelliJ, at least, has the ability to indent the code according to the nesting level. This makes missing or superfluous braces obvious. |
|
#27
| |||
| |||
| On Wed, 27 Aug 2008, Mike Schilling wrote: > Tom Anderson wrote: >> This: >> >> int place ; >> while ((place = s.indexOf(x)) >= 0 ) ... >> >> Can be written: >> >> for (int place; (place = s.indexOf(x)) >= 0 ...> > Or > > for (int place = s.indexOf(x); place >= 0; place = s.indexOf(x)) > > Which isn't bad except for the redunancy in the first and third clauses. Even worse! More characters duplicated, and a duplication where differences between the two won't be caught by the compiler - with the duplicated variable name, they probably will. tom -- I have been trying to find a way of framing this but yes, a light meal is probably preferable to a heavy one under the circumstances. -- ninebelow |
|
#28
| |||
| |||
| On Thu, 28 Aug 2008, Roedy Green wrote: > On Wed, 27 Aug 2008 12:39:23 +0100, Tom Anderson > <twic@urchin.earth.li> wrote, quoted or indirectly quoted someone who > said : > >> int x = (int y = 1) + 1; >> >> Isn't legal. This: > > Why not? I am not asking about the language as defined now, but what > the language designers might have been thinking when they concocted the > syntax. I would guess it just never occurred to them. The model of statements and expressions, with the former containing the latter but not vice versa, is a very ancient one, that has generally served us pretty well. tom -- I have been trying to find a way of framing this but yes, a light meal is probably preferable to a heavy one under the circumstances. -- ninebelow |
|
#29
| |||
| |||
| Tom Anderson <twic@urchin.earth.li> writes: >I would guess it just never occurred to them. The model of >statements and expressions, with the former containing the >latter but not vice versa, is a very ancient one, that has >generally served us pretty well. In Java, an expression /can/ contain a statement. In C, »( printf( "a" ), printf( "b" ))« is an expression for a sequence of evaluations at run time. Something statements are used for in many other languages. In LISP languages, there really is no such distinction, there only are nested lists in the source code (S-expressions). But some lists are more like statements, other more like expressions. In Assembler, there only are simple operations, which are more like statements. In pure functional languages, there are no statements nor sequences of evaluations. In natural language (English), there are noun phrases and verb phrases, which approximately correspond to expressions and statements, respectively. |
|
#30
| |||
| |||
| On Thu, 28 Aug 2008 08:10:48 -0700, Mike Schilling wrote: > Andreas Leitgeb wrote: >> Roedy Green <see_website@mindprod.com.invalid> wrote: >>> Figuring out nesting and fixing broken nesting is by far the syntax >>> feature of Java what wastes the most of my time and the one that I >>> find hardest just to eyeball. >> >> What editor do you use? Most editors designed for coding should have >> a feature "find matching paranthese/brace/bracket/...". >> In vi, it's "%". I've seen it in ultraedit as well (but don't remember >> the keyboard shortcut) and I'd be surprised, if eclipse and netbeans >> didn't have such a feature. > > IntelliJ, at least, has the ability to indent the code according to the > nesting level. This makes missing or superfluous braces obvious. It also indicates the matching brace by momentarily highlighting it. I like that, the syntax colouring, on-the-fly syntactic and semantic checks and its refactoring facilities, but I find its straight forward editing features and cursor movement capabilities disappointing. ymmv, but IMO its clunky editing really detract from its usability, so much so that its only marginally better than a non-language-aware editor. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.