You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Ralph Johnson <jo...@cs.uiuc.edu> on 2015/07/07 21:24:21 UTC

vararg syntax question

I switched compilers from 2.1.6 to 2.1.8 and something broke.  I am
thinking that perhaps an old language feature went away.

We have scripts that say something like

openModalWindow 'EditScreen', fromType: t1, withData: stuff

and it gets translated into a call on

def openModalWindow(Map options=[:], Object screenName) {

         ...

}

where options will be the map {fromType: t1, withData: stuff} except that
it has the values of the variables t1 and stuff.  Did this go away?  If so,
what should I replace it with?   I can't actually find documentation for
it, which leads me to believe it was deprecated.  I

Re: vararg syntax question

Posted by Ralph Johnson <jo...@cs.uiuc.edu>.
Thanks for your help.   The problem actually had nothing to do with vararg
syntax.   Instead, the link from the script to the methods in question
broke.   The methods were in a subclass of Script, and the script was
supposed to be an instance of this subclass, but it was instead just an
instance of Script.  Or rather, its class was a subclass of Script instead
of being a subclass of what it was supposed to be.   Anyway, once I quit
obsessing on the vararg syntax and started looking for other things that
could be wrong, I found it.

On Tue, Jul 7, 2015 at 3:03 PM, Keegan Witt <ke...@gmail.com> wrote:

> Maybe it's your compiler that broke, and not Groovy.  How are you
> compiling this?
>
> -Keegan
>
> On Tue, Jul 7, 2015 at 3:49 PM, Dinko Srkoč <di...@gmail.com> wrote:
>
>> I can't prove it, but I don't think anything changed between 2.1.6 and
>> 2.1.8 regarding handling (named) parameters. Even more, I don't think
>> anything changed there for a long time.
>>
>> I tried your example with 1.8.6, 2.1.6, 2.1.8, and 2.4.1 and all those
>> versions behave the same.
>>
>> Example that I tried:
>>
>>     def openModalWindow(Map options=[:], Object screenName) {
>>         println "screenName=$screenName, options=$options"
>>     }
>>
>>     def t1 = 'foo'
>>     def stuff = 42
>>
>>     openModalWindow 'EditScreen', fromType: t1, withData: stuff
>>     // prints: screenName=EditScreen, options=[fromType:foo, withData:42]
>>
>> Cheers,
>> Dinko
>>
>> On 7 July 2015 at 21:24, Ralph Johnson <jo...@cs.uiuc.edu> wrote:
>> > I switched compilers from 2.1.6 to 2.1.8 and something broke.  I am
>> thinking
>> > that perhaps an old language feature went away.
>> >
>> > We have scripts that say something like
>> >
>> > openModalWindow 'EditScreen', fromType: t1, withData: stuff
>> >
>> > and it gets translated into a call on
>> >
>> > def openModalWindow(Map options=[:], Object screenName) {
>> >
>> >          ...
>> >
>> > }
>> >
>> > where options will be the map {fromType: t1, withData: stuff} except
>> that it
>> > has the values of the variables t1 and stuff.  Did this go away?  If so,
>> > what should I replace it with?   I can't actually find documentation
>> for it,
>> > which leads me to believe it was deprecated.  I
>>
>
>

Re: vararg syntax question

Posted by Keegan Witt <ke...@gmail.com>.
Maybe it's your compiler that broke, and not Groovy.  How are you compiling
this?

-Keegan

On Tue, Jul 7, 2015 at 3:49 PM, Dinko Srkoč <di...@gmail.com> wrote:

> I can't prove it, but I don't think anything changed between 2.1.6 and
> 2.1.8 regarding handling (named) parameters. Even more, I don't think
> anything changed there for a long time.
>
> I tried your example with 1.8.6, 2.1.6, 2.1.8, and 2.4.1 and all those
> versions behave the same.
>
> Example that I tried:
>
>     def openModalWindow(Map options=[:], Object screenName) {
>         println "screenName=$screenName, options=$options"
>     }
>
>     def t1 = 'foo'
>     def stuff = 42
>
>     openModalWindow 'EditScreen', fromType: t1, withData: stuff
>     // prints: screenName=EditScreen, options=[fromType:foo, withData:42]
>
> Cheers,
> Dinko
>
> On 7 July 2015 at 21:24, Ralph Johnson <jo...@cs.uiuc.edu> wrote:
> > I switched compilers from 2.1.6 to 2.1.8 and something broke.  I am
> thinking
> > that perhaps an old language feature went away.
> >
> > We have scripts that say something like
> >
> > openModalWindow 'EditScreen', fromType: t1, withData: stuff
> >
> > and it gets translated into a call on
> >
> > def openModalWindow(Map options=[:], Object screenName) {
> >
> >          ...
> >
> > }
> >
> > where options will be the map {fromType: t1, withData: stuff} except
> that it
> > has the values of the variables t1 and stuff.  Did this go away?  If so,
> > what should I replace it with?   I can't actually find documentation for
> it,
> > which leads me to believe it was deprecated.  I
>

Re: vararg syntax question

Posted by Dinko Srkoč <di...@gmail.com>.
I can't prove it, but I don't think anything changed between 2.1.6 and
2.1.8 regarding handling (named) parameters. Even more, I don't think
anything changed there for a long time.

I tried your example with 1.8.6, 2.1.6, 2.1.8, and 2.4.1 and all those
versions behave the same.

Example that I tried:

    def openModalWindow(Map options=[:], Object screenName) {
        println "screenName=$screenName, options=$options"
    }

    def t1 = 'foo'
    def stuff = 42

    openModalWindow 'EditScreen', fromType: t1, withData: stuff
    // prints: screenName=EditScreen, options=[fromType:foo, withData:42]

Cheers,
Dinko

On 7 July 2015 at 21:24, Ralph Johnson <jo...@cs.uiuc.edu> wrote:
> I switched compilers from 2.1.6 to 2.1.8 and something broke.  I am thinking
> that perhaps an old language feature went away.
>
> We have scripts that say something like
>
> openModalWindow 'EditScreen', fromType: t1, withData: stuff
>
> and it gets translated into a call on
>
> def openModalWindow(Map options=[:], Object screenName) {
>
>          ...
>
> }
>
> where options will be the map {fromType: t1, withData: stuff} except that it
> has the values of the variables t1 and stuff.  Did this go away?  If so,
> what should I replace it with?   I can't actually find documentation for it,
> which leads me to believe it was deprecated.  I