aalmiray | 1 Jul 2010 12:06
Picon
Favicon
Gravatar

[groovy-dev] Potential ConfigObject.writeTo() enhancement?


ConfigObject.writeTo() uses tabs to write the indentation for each
node/value. Does it make sense to have another writeTo() method that takes a
numberic value that represents the number of spaces to be used instead of a
tab?
--

-- 
View this message in context: http://groovy.329449.n5.nabble.com/Potential-ConfigObject-writeTo-enhancement-tp512347p512347.html
Sent from the groovy - dev mailing list archive at Nabble.com.

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

    http://xircles.codehaus.org/manage_email

Peter Niederwieser | 1 Jul 2010 22:42
Picon
Gravatar

[groovy-dev] Annotation closures available in trunk


Annotation closures are now available in trunk. Here is how you use them:

 <at> Retention(RetentionPolicy.RUNTIME)
 <at> interface Require {
  Class value()
}

 <at> Require({ 1 < 2 })
class Foo {}

def reqClass = Foo.class.getAnnotation(Require).value()
Closure req = reqClass.newInstance(null, null) // owner, thisObject
assert req()

I also experimented with modifying the grammar s.t. I could leave off the
parens as in...
 <at> Require { 1 < 2 }
...but failed miserably due to insufficient ANTLR knowledge. Would you
welcome this change? If yes, would someone help me to implement a prototype?

Cheers,
Peter

--

-- 
View this message in context: http://groovy.329449.n5.nabble.com/Annotation-closures-available-in-trunk-tp512450p512450.html
Sent from the groovy - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:
(Continue reading)

Andre Steingress | 1 Jul 2010 22:55
Gravatar

Re: [groovy-dev] Annotation closures available in trunk

Great work!

really looking forward for branching GContracts for 1.8 - up to know the closure annotation replacement
transformation has been a real hack...

Cheers,
Andre

Am 01.07.2010 um 22:42 schrieb Peter Niederwieser <pniederw@...>:

> 
> Annotation closures are now available in trunk. Here is how you use them:
> 
>  <at> Retention(RetentionPolicy.RUNTIME)
>  <at> interface Require {
>  Class value()
> }
> 
>  <at> Require({ 1 < 2 })
> class Foo {}
> 
> def reqClass = Foo.class.getAnnotation(Require).value()
> Closure req = reqClass.newInstance(null, null) // owner, thisObject
> assert req()
> 
> I also experimented with modifying the grammar s.t. I could leave off the
> parens as in...
>  <at> Require { 1 < 2 }
> ...but failed miserably due to insufficient ANTLR knowledge. Would you
> welcome this change? If yes, would someone help me to implement a prototype?
(Continue reading)

Peter Niederwieser | 1 Jul 2010 23:04
Picon
Gravatar

[groovy-dev] Re: Annotation closures available in trunk


Andre,

I can't see how this is going to help GContracts' implementation. How do you
intend to use this?

Cheers,
Peter
--

-- 
View this message in context: http://groovy.329449.n5.nabble.com/Annotation-closures-available-in-trunk-tp512450p512455.html
Sent from the groovy - dev mailing list archive at Nabble.com.

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

    http://xircles.codehaus.org/manage_email

aalmiray | 1 Jul 2010 23:22
Picon
Favicon
Gravatar

[groovy-dev] Re: Annotation closures available in trunk


Awesome! However I'm a bit concerned of any potential conflicts with a recent
addition to Griffon: the  <at> Listener AST xform ->
http://git.codehaus.org/gitweb.cgi?p=griffon-git.git;a=blob_plain;f=src/cli/org/codehaus/griffon/ast/ListenerASTTransformation.java;hb=GRIFFON_0.3.X

Sample usage:
--------------------------------
import griffon.util.Listener
import groovy.beans.Bindable

class MyModel {
     <at> Bindable
     <at> Listener({controller.someAction(it)})
    String name

     <at> Bindable
     <at> Listener(myListener)
    String value

    def myListener = { ... }
}
--------------------------------

This AST xform generates an inner class for the first prop, it casts the
closure to a PropertyChangeListener on the second case. But I guess that as
long closures as values are supported in a case by case basis... then
Griffon is fine.
--

-- 
View this message in context: http://groovy.329449.n5.nabble.com/Annotation-closures-available-in-trunk-tp512450p512458.html
Sent from the groovy - dev mailing list archive at Nabble.com.
(Continue reading)

Peter Niederwieser | 1 Jul 2010 23:45
Picon
Gravatar

[groovy-dev] Re: Annotation closures available in trunk


> This AST xform generates an inner class for the first prop, it casts the
closure to a PropertyChangeListener on the second case.
I'd be cautious about the second case; it seems to be turning invalid into
valid Groovy code, which will likely break tools (IDEs in particular) and
joint compilation.

> But I guess that as long closures as values are supported in a case by
> case basis... then Griffon is fine.
What do you mean by that?

AST transforms playing their own games with annotation closures should be
fine because groovyc won't touch the closures until phase class generation.
Ideally, transforms would keep replacing the closure with a class literal to
prevent generation of another inner class.

Cheers,
Peter
--

-- 
View this message in context: http://groovy.329449.n5.nabble.com/Annotation-closures-available-in-trunk-tp512450p512466.html
Sent from the groovy - dev mailing list archive at Nabble.com.

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

    http://xircles.codehaus.org/manage_email

Peter Niederwieser | 1 Jul 2010 23:59
Picon
Gravatar

[groovy-dev] Are there plans to support Java 7 features in Groovy 1.8?


Are there plans to support some of the proposed Java 7 features in Groovy
1.8? For example, I really like the "catch (ExceptionA | ExceptionB)" idea,
and it should be fairly easy to implement.

Cheers,
Peter
--

-- 
View this message in context: http://groovy.329449.n5.nabble.com/Are-there-plans-to-support-Java-7-features-in-Groovy-1-8-tp512472p512472.html
Sent from the groovy - dev mailing list archive at Nabble.com.

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

    http://xircles.codehaus.org/manage_email

Andre Steingress | 2 Jul 2010 05:56
Gravatar

Re: [groovy-dev] Re: Annotation closures available in trunk

There is no need to transform closure annotations to valid groovy code by replacing it with Object.class anymore.

Am 01.07.2010 um 23:04 schrieb Peter Niederwieser <pniederw@...>:

> 
> Andre,
> 
> I can't see how this is going to help GContracts' implementation. How do you
> intend to use this?
> 
> Cheers,
> Peter
> -- 
> View this message in context: http://groovy.329449.n5.nabble.com/Annotation-closures-available-in-trunk-tp512450p512455.html
> Sent from the groovy - dev mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>    http://xircles.codehaus.org/manage_email
> 
> 

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

    http://xircles.codehaus.org/manage_email

aalmiray | 2 Jul 2010 08:35
Picon
Favicon
Gravatar

[groovy-dev] Re: Annotation closures available in trunk


Peter Niederwieser wrote:
> 
>> This AST xform generates an inner class for the first prop, it casts the
>> closure to a PropertyChangeListener on the second case.
> I'd be cautious about the second case; it seems to be turning invalid into
> valid Groovy code, which will likely break tools (IDEs in particular) and
> joint compilation.
> 

Actually the code is roughly equivalent to this

import griffon.util.Listener
import groovy.beans.Bindable

class MyModel {
     <at> Bindable
    String name

     <at> Bindable
    String value

    def myListener = { ... }

    MyModel() {
        addPropertyChangeListener('name', new PropertyChangeListener() {
           void propertyChange(PropertyChangeEvent evt) {
               contrtoller.someAction(evt)
           }
        })
(Continue reading)

Peter Niederwieser | 2 Jul 2010 11:52
Picon
Gravatar

[groovy-dev] Re: Annotation closures available in trunk


aalmiray wrote:
> 
> So as long as the 'myListener' property has a closure value that takes a
> single param we're covered (the AST xform does check the value to be a
> closure but not the # of args)
> 

Referencing a property from an annotation is still invalid Groovy code.
Tools won't be able to make sense of it.

aalmiray wrote:
> 
> Then again, as long as my own AST xforms can translate the closure value
> to something else, not just a class literal then there won't be any clash.
> 

The class literal is just a dummy value you stick into the annotation at the
end, to calm down the compiler (I used to use Object.class for this). You
can now skip this step, at the expense of creating a class for the closure.

Cheers,
Peter
--

-- 
View this message in context: http://groovy.329449.n5.nabble.com/Annotation-closures-available-in-trunk-tp512450p512609.html
Sent from the groovy - dev mailing list archive at Nabble.com.

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

(Continue reading)


Gmane