Re: Lists in annotations

2025-04-11 Thread Paul King
I'd raise a separate thread since this is now off-topic for the original thread. But, yes, the JDK doesn't have native support for named arguments, so if you use named arguments, some argument collecting will occur. The map, as first parameter, is the well-documented approach we use for Java integr

Re: [EXT] Lists in annotations

2025-04-11 Thread o...@ocs.cz
> def foo(Map a, b, c) { > // ... > } > > foo(a:'a', 'b', 'c', x: 'also a') > From: o...@ocs.cz > Sent: Friday, April 11, 2025 9:16 AM > To: Groovy_Developers > Subject: [EXT] Re: Lists in annotations > > External Email:

Re: [EXT] Re: Lists in annotations

2025-04-11 Thread Milles, Eric (TR Technology) via dev
Just an FYI, the support for @A({ ... }) is tracked by https://issues.apache.org/jira/browse/GROOVY-11492 From: Paul King Sent: Friday, April 11, 2025 5:20 AM To: dev@groovy.apache.org Subject: [EXT] Re: Lists in annotations External Email: Use caution with

Re: Lists in annotations

2025-04-11 Thread o...@ocs.cz
Christopher, > On 11. 4. 2025, at 15:55, Christopher Smith wrote: > I personally find it surprising and confusing that arguments are implicitly > collected in method calls; I recently was baffled until I realized that the > Map as a first argument was causing Groovy to group the leading argumen

Re: [EXT] Re: Lists in annotations

2025-04-11 Thread Milles, Eric (TR Technology) via dev
When a Map is the first parameter, it acts as a collector for any named parameters. def foo(Map a, b, c) { // ... } foo(a:'a', 'b', 'c', x: 'also a') From: o...@ocs.cz Sent: Friday, April 11, 2025 9:16 AM To: Groovy

Re: Lists in annotations

2025-04-11 Thread o...@ocs.cz
P.S. Sorry I see I forgot to add the test for the seconds case (caller side Map, no such thing at the receiver): === 1054 ocs /tmp> /usr/local/groovy-4.0.25/bin/groovy q a:[a:1] b:Hi c:there 1056 ocs /tmp> === > On 11. 4. 2025, at 16:12, o...@ocs.cz wrote: > > Christopher, > >> On 11. 4. 2025

Re: Lists in annotations

2025-04-11 Thread Christopher Smith
I personally find it surprising and confusing that arguments are implicitly collected in method calls; I recently was baffled until I realized that the Map as a first argument was causing Groovy to group the leading arguments. I appreciate Groovy's syntactic sugar for clear cases (such as trailing

Re: Lists in annotations

2025-04-11 Thread Paul King
I think it is just the case that Java supports only a single value or array notation, so that's what we did too (just adapting to Groovy array/list notation). We have certainly had folks ask if we could also support the curly brace syntax but that clashes with a closure. It would be interesting t

Lists in annotations

2025-04-11 Thread Gianluca Sartori
Hi folks, we use the following well known annotation in our Grails controllers: @Secured(['ROLE_USER', 'ROLE_OTHER']) I was wondering why we cannot write this instead: @Secured('ROLE_USER', 'ROLE_OTHER') like in method calls. To your knowledge is that a Groovy thing or it lies somewhere else?