[ 
https://issues.apache.org/jira/browse/GROOVY-11878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18069149#comment-18069149
 ] 

ASF GitHub Bot commented on GROOVY-11878:
-----------------------------------------

paulk-asert commented on PR #2400:
URL: https://github.com/apache/groovy/pull/2400#issuecomment-4145681135

   Thanks. I wasn't intending to including the @Parallel annotation and 
transform but for now I'll mark then as @Incubating and we can think more about 
whether we'd include them or polish them. I think that is fine for an alpha 
release but we'd want to make a final decision before beta-1.




> Allow AST transforms to be applicable in more places, initially loop 
> statements
> -------------------------------------------------------------------------------
>
>                 Key: GROOVY-11878
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11878
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 6.0.0-alpha-1
>
>
> The JVM doesn't support adding annotations in the bytecode for statements and 
> expressions. That doesn't mean that Groovy couldn't support source-level AST 
> transforms in those places. Code injection can happen in the normal way, and 
> the transform will be "forgotten" after compilation.
>  Examples might be:
> {code}
> @Parallel
> for (int i in 1..4) {
>     println i ** 2
> }
> {code}
> which might have this output:
> {noformat}
> 1
> 16
> 9
> 4
> {noformat}
> Or these:
> {code}
> int sum = 0
> @Invariant({ 0 <= i && i <= 4 })
> for (int i in 0..4) {
>     sum += i
> }
> assert sum == 10
> {code}
> {code}
> int i = 10
> @Invariant({ i >= 0 })
> @Ensures({ i > old.i }) // i decreases
> while (i > 0) {
>     i = i - 1
> }
> assert i == 0
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to