groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Assia Alexandrova <kob...@gmail.com>
Subject Re: JSR 223 support behavior
Date Tue, 23 May 2017 01:34:03 GMT
Hi,

Thanks for the prompt response!

I am a bit confused. According to what appears to be the official
language semantics:

http://www.groovy-lang.org/semantics.html#_variable_definition

the 'def' keyword is used to declare an untyped variable (i.e. one
whose type is Object). So something like

def x = 10

is then presumably equivalent to two separate statements:

def x
x = 10

What is the difference in semantics between 'def x = 10' and 'x = 10'?

Can you point me to how docs where I can learn about transforms and
write such a transform? I'd like to understand if this behaviors is
some side-effect of the implementation of the language or really
designed following some rationale. In the latter case, cool, but in
the former, I'd take a stab at a writing a transform. The following
REPL interaction seems too strange to me :-)

groovy:000> def x = 10;

===> 10

groovy:000> x

Unknown property: x


Regards

On Mon, May 22, 2017 at 1:35 AM, Jochen Theodorou <blackdrag@gmx.org> wrote:
>
> On 22.05.2017 06:53, Assia Alexandrova wrote:
>>
>> Hi all,
>>
>> My first time here. I wasn't sure weather to post this to dev list, so
>> please let me know if I should!
>>
>> I'm trying to hook the latest Groovy interpreter to a JVM scripting
>> notebook environment (https://github.com/bolerio/seco). At a minimum I
>> need good JSR 223 support so that symbols/variables can be shared
>> between scripting languages. With Groovy and its built-in JSR 223
>> support, it seems like an assignment:
>>
>> something = 10
>>
>> is placed into the common scripting context, but not a definition like this:
>>
>> def something = 10
>
>
> that is by language design
>
>
> [...]
>>
>> Is this a bug? If not, is there a way to get access to those symbols
>> introduced via 'def'. Disclaimer: I'm not a Groovy programmer, just
>> trying to learn enough to make this work.
>
>
> you could write a transform to rewrite the code for those.
>
> But why not simply use it without def?
>
> bye Jochen
>

Mime
View raw message