groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Amerige <Steve.Amer...@sas.com>
Subject Changing the default to TypeChecked
Date Wed, 27 May 2015 16:00:59 GMT
Hi all,

Jochen showed us how to default to CompileStatic 
<http://groovy.329449.n5.nabble.com/Changing-the-default-to-CompileStatic-tp5723113p5723114.html>

in a post a few months ago.  A question was raised about about changing 
the default to TypeChecked for the case where a user doesn't want 
CompileStatic as a default, but does want TypeChecked as a default.  
Would it be the same solution as above? That is:

*config.groovy*

    withConfig(configuration) {
         ast(groovy.transform.TypeChecked)
    }

and then do: groovyc -configscriptsrc/conf/config.groovy 
src/main/groovy/MyClass.groovy

Also, if one were to specify:

*config.groovy*

    withConfig(configuration) {
         ast(groovy.transform.CompileStatic)
    }

would that also mean that TypeChecked is enabled by default?  How is it 
disabled for a given class or method?  Or, would one need to do the 
following?

*config.groovy*

    withConfig(configuration) {
         ast(groovy.transform.CompileStatic)
         ast(groovy.transform.TypeChecked)
    }

In summary, I'm asking:

 1. Is adding ast(groovy.transform.TypeChecked) in the config file how
    to turn on TypeChecked by default?
 2. What is the idiom to disable TypeChecked for a given class or method?
 3. Does CompileStatic imply TypeChecked (so that if CompileStatic is
    specified, it is not necessary to specify TypeChecked in a config file)?

Thanks,
Steve Amerige
Principal Software Developer, Fraud and Compliance Solutions Development
SAS Institute, 100 SAS Campus Dr, Room U3050, Cary, NC 27513-8617



P.S.  By the way, having the ability to set the default for strong type 
checking and static compilation while at the same time allowing for 
specific exceptions (via @CompileDynamic, for example) has been very 
useful in reducing push-back regarding Groovy adoption. Similarly, 
disallowing @Grab 
<http://groovy.329449.n5.nabble.com/Disabling-Grape-tp5720694p5721122.html> 
as C├ędric suggests is also part of helps enterprises embrace Groovy. I 
encourage people to promote this and other similar features when 
encountering resistance!  I think there should be an entire section in 
the documentation that focuses on issues like these that are of interest 
to large enterprises.

Mime
View raw message