Fedora Linux Support Community & Resources Center
  #1  
Old 28th April 2012, 11:41 PM
marko Online
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,049
linuxfirefox
groovyConsole -- doesn't it support commas in for loops?

Is anyone doing much groovy with groovyConsole? I've noticed that if I make a for look with commas groovy won't accept it in the GUI console:

Code:
    int b = 4
    for (int a = 0; a < b; a++,b--) {
        //b--
        println "a: " + a + " b: " + b
    }
 
1 compilation error:
expecting ")" found ","  ....
then if I remove the ", b--" and comment back in the "// b-- " it works fine
Code:
a: 0 b: 3
a: 1 b: 2
But commas in the for statement are valid Java. This is with Groovy version 1.8.6 on Oracle JDK 1.6.0_31 64bit on Fedora 16. Is this a limitation in the groovyConsole?
Reply With Quote
  #2  
Old 30th April 2012, 04:42 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,650
linuxfedorafirefox
Re: groovyConsole -- doesn't it support commas in for loops?

It might be a groovyConsole problem. It works fine for me in BeanShell:
Attached Thumbnails
Click image for larger version

Name:	forloop.png
Views:	83
Size:	16.8 KB
ID:	23007  
__________________
"I'm not glad he's dead, but I'm glad he's gone."
-- Richard M. Stallman, on the death of Steve Jobs
Reply With Quote
  #3  
Old 1st May 2012, 01:16 AM
marko Online
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,049
linuxfirefox
Re: groovyConsole -- doesn't it support commas in for loops?

Quote:
Originally Posted by RupertPupkin View Post
It might be a groovyConsole problem. It works fine for me in BeanShell:
But you're using BeanShell script language (is just the same as Java?) there and not groovy....
Reply With Quote
  #4  
Old 1st May 2012, 05:17 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,650
linuxfedorafirefox
Re: groovyConsole -- doesn't it support commas in for loops?

BeanShell and Groovy are similar in that they are both Java-based scripting languages that have their own syntax but accept pure Java code. So if you just need the Java aspect then you could use BeanShell instead of Groovy, since Groovy's Java interpreter seems to be broken. I've never had any problem using pure Java in BeanShell. which is why I use it all the time for quick testing.
__________________
"I'm not glad he's dead, but I'm glad he's gone."
-- Richard M. Stallman, on the death of Steve Jobs
Reply With Quote
  #5  
Old 8th May 2012, 04:32 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,650
linuxfedorafirefox
Re: groovyConsole -- doesn't it support commas in for loops?

Hmm, looks like this is broken not just in groovyConsole but in Groovy itself:
Code:
$ groovy -v
Groovy Version: 1.8.6 JVM: 1.7.0_03 Vendor: Oracle Corporation OS: Linux
$ cat forloop.groovy
int b = 4
for (int a = 0; a < b; a++,b--) {
    println "a: " + a + " b: " + b
}
$ groovy forloop.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/code/groovy/forloop.groovy: 2: expecting ')', found ',' @ line 2, column 27.
   for (int a = 0; a < b; a++,b--) {
                             ^

1 error
Someone should file a bug to fix Groovy's Java support!
__________________
"I'm not glad he's dead, but I'm glad he's gone."
-- Richard M. Stallman, on the death of Steve Jobs
Reply With Quote
Reply

Tags
commas, groovyconsole, loops, support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tux and Froot Loops Vespa Linux Chat 21 26th January 2011 04:03 PM
how to use less CPU on loops CowTux Programming & Packaging 2 24th August 2010 08:10 PM
Using sed to add commas to new lines. lynxus Using Fedora 2 16th December 2009 12:17 PM
C++ question about loops girgori Programming & Packaging 8 28th September 2006 05:49 AM


Current GMT-time: 02:01 (Monday, 15-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat