do while

classic Classic list List threaded Threaded
11 messages Options
12
Reply | Threaded
Open this post in threaded view
|

do while

Dierk König
Hi gents,

is there any special reason why Groovy doesn't have a
 do {} while ()
control structure like Java?

cheers
Dierk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: do while

Travis Schneeberger
I found this when I was preparing for a groovy for a presentation.  Doesn't really tell you much:

http://groovy.codehaus.org/Migration+From+Classic+to+JSR+syntax

On Thu, Nov 10, 2011 at 8:07 AM, Dierk König <[hidden email]> wrote:
Hi gents,

is there any special reason why Groovy doesn't have a
 do {} while ()
control structure like Java?

cheers
Dierk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: do while

Guillaume Laforge-4
In reply to this post by Dierk König
I think it was due to whitespace sensitivity, as someone could have created a do {} method taking a closure, and the while() could have been a normal while, or something like that.
The details escape me a little now (was a decision of 2003 or 2004).

Guillaume

On Thu, Nov 10, 2011 at 19:07, Dierk König <[hidden email]> wrote:
Hi gents,

is there any special reason why Groovy doesn't have a
 do {} while ()
control structure like Java?

cheers
Dierk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one
Reply | Threaded
Open this post in threaded view
|

Re: do while

Dierk König

> I think it was due to whitespace sensitivity, as someone could have created a do {} method taking a closure, and the while() could have been a normal while, or something like that.
> The details escape me a little now (was a decision of 2003 or 2004).

And does the argument still hold?

I mean, the situation is not different from
 times { }
and since the introdUction of the "no silly statement" rule, we could support it, or not?

cheers
Dierk


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: do while

Jochen Theodorou
Am 10.11.2011 19:55, schrieb Dierk König:
>
>> I think it was due to whitespace sensitivity, as someone could have created a do {} method taking a closure, and the while() could have been a normal while, or something like that.
>> The details escape me a little now (was a decision of 2003 or 2004).
>
> And does the argument still hold?
>
> I mean, the situation is not different from
>   times { }
> and since the introdUction of the "no silly statement" rule, we could support it, or not?

if you go with what Guillaume said, then we cannot, because the do
statement would need a keyword and that makes do unusable as method name...

If we agree to break the older programs in that, then we can implement
it I guess.

bye blackdrag

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: do while

Jim White-2
In reply to this post by Guillaume Laforge-4
Oh wow.  I didn't even know Groovy didn't implement do-while.

Obviously I'm not inclined to use it but I think it is important for
Groovy to implement Java as fully as possible.  A major point I make in
selling Groovy to Java folks is that it is a Java superset and so makes
the most out of what they already know and love (or hate as the case may
be).

Is it true that 'do' is not a reserved word in Groovy?  If so, then
implementing do-while will be a bit incompatible for folks who do weird
things and so should only be changed into one at a major revision (as it
should have been to start with - regardless of whether do-while was
considered implementable).  1.9 is a good time to make it a reserved
word, even if there isn't a do-while implementation yet.  And if there
are any other Java reserved words that aren't reserved in Groovy, then
they should get that treatment too.

Jim

On 11/10/11 10:40 AM, Guillaume Laforge wrote:

> I think it was due to whitespace sensitivity, as someone could have
> created a do {} method taking a closure, and the while() could have been
> a normal while, or something like that.
> The details escape me a little now (was a decision of 2003 or 2004).
>
> Guillaume
>
> On Thu, Nov 10, 2011 at 19:07, Dierk König <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi gents,
>
>     is there any special reason why Groovy doesn't have a
>       do {} while ()
>     control structure like Java?
>
>     cheers
>     Dierk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: do while

Guillaume Laforge-4
The parser seems to complain about using do in variable names or method names, so it would appear that it shouldn't really be problematic if we supported that.

Interestingly, it's the first time in years that someone notices that Groovy doesn't support do / while!

Guillaume

On Thu, Nov 10, 2011 at 23:24, Jim White <[hidden email]> wrote:
Oh wow.  I didn't even know Groovy didn't implement do-while.

Obviously I'm not inclined to use it but I think it is important for Groovy to implement Java as fully as possible.  A major point I make in selling Groovy to Java folks is that it is a Java superset and so makes the most out of what they already know and love (or hate as the case may be).

Is it true that 'do' is not a reserved word in Groovy?  If so, then implementing do-while will be a bit incompatible for folks who do weird things and so should only be changed into one at a major revision (as it should have been to start with - regardless of whether do-while was considered implementable).  1.9 is a good time to make it a reserved word, even if there isn't a do-while implementation yet.  And if there are any other Java reserved words that aren't reserved in Groovy, then they should get that treatment too.

Jim


On 11/10/11 10:40 AM, Guillaume Laforge wrote:
I think it was due to whitespace sensitivity, as someone could have
created a do {} method taking a closure, and the while() could have been
a normal while, or something like that.
The details escape me a little now (was a decision of 2003 or 2004).

Guillaume

On Thu, Nov 10, 2011 at 19:07, Dierk König <[hidden email]
<mailto:[hidden email]>> wrote:

   Hi gents,

   is there any special reason why Groovy doesn't have a
     do {} while ()
   control structure like Java?

   cheers
   Dierk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email





--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one
Reply | Threaded
Open this post in threaded view
|

Re: do while

Jon Cox

  Guillaume,

    Interesting.

    Supposedly do {} while(...) is slightly more efficient
    as well -- 1 branch instead of 2.

                -Jon


* Guillaume Laforge ([hidden email]) [111110 14:38]:

> The parser seems to complain about using do in variable names or method
> names, so it would appear that it shouldn't really be problematic if we
> supported that.
>
> Interestingly, it's the first time in years that someone notices that
> Groovy doesn't support do / while!
>
> Guillaume
>
> On Thu, Nov 10, 2011 at 23:24, Jim White <[hidden email]> wrote:
>
> > Oh wow.  I didn't even know Groovy didn't implement do-while.
> >
> > Obviously I'm not inclined to use it but I think it is important for
> > Groovy to implement Java as fully as possible.  A major point I make in
> > selling Groovy to Java folks is that it is a Java superset and so makes the
> > most out of what they already know and love (or hate as the case may be).
> >
> > Is it true that 'do' is not a reserved word in Groovy?  If so, then
> > implementing do-while will be a bit incompatible for folks who do weird
> > things and so should only be changed into one at a major revision (as it
> > should have been to start with - regardless of whether do-while was
> > considered implementable).  1.9 is a good time to make it a reserved word,
> > even if there isn't a do-while implementation yet.  And if there are any
> > other Java reserved words that aren't reserved in Groovy, then they should
> > get that treatment too.
> >
> > Jim
> >
> >
> > On 11/10/11 10:40 AM, Guillaume Laforge wrote:
> >
> >> I think it was due to whitespace sensitivity, as someone could have
> >> created a do {} method taking a closure, and the while() could have been
> >> a normal while, or something like that.
> >> The details escape me a little now (was a decision of 2003 or 2004).
> >>
> >> Guillaume
> >>
> >> On Thu, Nov 10, 2011 at 19:07, Dierk K?nig <[hidden email]
> >> <mailto:[hidden email]**>> wrote:
> >>
> >>    Hi gents,
> >>
> >>    is there any special reason why Groovy doesn't have a
> >>      do {} while ()
> >>    control structure like Java?
> >>
> >>    cheers
> >>    Dierk
> >>
> >
> > ------------------------------**------------------------------**---------
> > To unsubscribe from this list, please visit:
> >
> >   http://xircles.codehaus.org/**manage_email<http://xircles.codehaus.org/manage_email>
> >
> >
> >
>
>
> --
> Guillaume Laforge
> Groovy Project Manager
> Head of Groovy Development at SpringSource
> http://www.springsource.com/g2one

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: do while

Dierk König
In reply to this post by Guillaume Laforge-4
> Interestingly, it's the first time in years that someone notices that Groovy doesn't support do / while!

To give due credit, it was actually one of my clients who recognized this when
moving Java to Groovy.

To show my full ignorance: I had even forgotten that Java has a do-while. I never used it.

:-)
Dierk




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: do while

Remi Forax
In reply to this post by Jon Cox
On 11/11/2011 03:43 AM, Jon Cox wrote:
>    Guillaume,
>
>      Interesting.
>
>      Supposedly do {} while(...) is slightly more efficient
>      as well -- 1 branch instead of 2.
>
>                  -Jon

The supplementary jump is done once,
while() is usually translated to

goto test;
do {
   ...
   test:
}
while (...)

Rémi


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


12