You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by "matthias.grueter@gmail.com" <ma...@gmail.com> on 2016/02/27 23:08:32 UTC

Optional parentheses for methods with all uppercase names

[First off I apologize for possibly reposting this question. My original
posting never went out to the maillist due to unknown reasons. This is my
second attempt. Sorry if you already read this before.]

I am a developing a Groovy DSL to create Dockerfiles

The format of a Dockerfile looks like:

INSTRUCTION arguments

Instructions are case-insensitive but convention is for them to be
UPPERCASE.

However Groovy doesn't seem to support optional parentheses if the method
name is all uppercase:

def FOOBAR(String msg) {
println msg
}
FOOBAR "hello"

groovyc: unexpected token: hello @ line 2, column 8.
FOOBAR "hello"
^

Do you know of any way to get this to work or is this a known limitation of
Groovy?

I tried with Groovy version 2.4.5

If anyone has any insight, it would be very helpful.

/matthias

-- 
Matthias Grüter
www.grueter.name   //   matthias@grueter.name

RE: Optional parentheses for methods with all uppercase names

Posted by "Winnebeck, Jason" <Ja...@windstream.com>.
I didn't see this explanation in the linked thread, but from what I've heard in situations where a symbol can be interpreted as a function or a Class, the rule that is used to choose between the cases is the initial uppercase letter. So "Foo" is the name of a class but "foo" is the name of a local symbol or function. That makes "String x" a variable declaration but "string x" a call to "string(x)".

Jason

-----Original Message-----
From: OC [mailto:ocs@ocs.cz] 
Sent: Sunday, February 28, 2016 11:49 AM
To: users@groovy.apache.org
Subject: Re: Optional parentheses for methods with all uppercase names

We have bumped into this parser issue long long ago, see

http://www.groovy-lang.org/mailing-lists.html#nabble-td5722268

All the best,
OC

On 27. 2. 2016, at 23:19, Bay Batu <ba...@gmail.com> wrote:

> Hello,
> 
> I tried it and it looks like an issue about first letter's case. 
> 
> For example,
> 
> *********
> def Foo(a){
> 	print a
> }
> 
> Foo "berbat"
> *********
> gives compilation error: unexpected token berbat
> 
> But it does not give a compilation error when i change it like that.
> 
> *********
> def fOo(a){
> 	print a
> }
> 
> fOo "berbat"
> *********
> 
> /baybatu
> 
> 
> 
> 
> 
> 
>> On Feb 28, 2016, at 00:08, matthias.grueter@gmail.com wrote:
>> 
>> [First off I apologize for possibly reposting this question. My original posting never went out to the maillist due to unknown reasons. This is my second attempt. Sorry if you already read this before.]
>> 
>> I am a developing a Groovy DSL to create Dockerfiles
>> 
>> The format of a Dockerfile looks like:
>> 
>> INSTRUCTION arguments
>> 
>> Instructions are case-insensitive but convention is for them to be UPPERCASE.
>> 
>> However Groovy doesn't seem to support optional parentheses if the method name is all uppercase:
>> 
>> def FOOBAR(String msg) {
>> println msg
>> }
>> FOOBAR "hello"
>> 
>> groovyc: unexpected token: hello @ line 2, column 8.
>> FOOBAR "hello"
>> ^
>> 
>> Do you know of any way to get this to work or is this a known limitation of Groovy?
>> 
>> I tried with Groovy version 2.4.5
>> 
>> If anyone has any insight, it would be very helpful.
>> 
>> /matthias 
>> 
>> -- 
>> Matthias Grüter
>> www.grueter.name   //   matthias@grueter.name
> 

----------------------------------------------------------------------
This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.

Re: Optional parentheses for methods with all uppercase names

Posted by OC <oc...@ocs.cz>.
We have bumped into this parser issue long long ago, see

http://www.groovy-lang.org/mailing-lists.html#nabble-td5722268

All the best,
OC

On 27. 2. 2016, at 23:19, Bay Batu <ba...@gmail.com> wrote:

> Hello,
> 
> I tried it and it looks like an issue about first letter’s case. 
> 
> For example,
> 
> *********
> def Foo(a){
> 	print a
> }
> 
> Foo “berbat"
> *********
> gives compilation error: unexpected token berbat
> 
> But it does not give a compilation error when i change it like that.
> 
> *********
> def fOo(a){
> 	print a
> }
> 
> fOo “berbat"
> *********
> 
> /baybatu
> 
> 
> 
> 
> 
> 
>> On Feb 28, 2016, at 00:08, matthias.grueter@gmail.com wrote:
>> 
>> [First off I apologize for possibly reposting this question. My original posting never went out to the maillist due to unknown reasons. This is my second attempt. Sorry if you already read this before.]
>> 
>> I am a developing a Groovy DSL to create Dockerfiles
>> 
>> The format of a Dockerfile looks like:
>> 
>> INSTRUCTION arguments
>> 
>> Instructions are case-insensitive but convention is for them to be UPPERCASE.
>> 
>> However Groovy doesn't seem to support optional parentheses if the method name is all uppercase:
>> 
>> def FOOBAR(String msg) {
>> println msg
>> }
>> FOOBAR "hello"
>> 
>> groovyc: unexpected token: hello @ line 2, column 8.
>> FOOBAR "hello"
>> ^
>> 
>> Do you know of any way to get this to work or is this a known limitation of Groovy?
>> 
>> I tried with Groovy version 2.4.5
>> 
>> If anyone has any insight, it would be very helpful.
>> 
>> /matthias 
>> 
>> -- 
>> Matthias Grüter
>> www.grueter.name   //   matthias@grueter.name
> 


Re: Optional parentheses for methods with all uppercase names

Posted by Bay Batu <ba...@gmail.com>.
Hello,

I tried it and it looks like an issue about first letter’s case. 

For example,

*********
def Foo(a){
	print a
}

Foo “berbat"
*********
gives compilation error: unexpected token berbat

But it does not give a compilation error when i change it like that.

*********
def fOo(a){
	print a
}

fOo “berbat"
*********

/baybatu


 <file://consolescript:5/>
 <file://consolescript:5/>
> On Feb 28, 2016, at 00:08, matthias.grueter@gmail.com wrote:
> 
> [First off I apologize for possibly reposting this question. My original posting never went out to the maillist due to unknown reasons. This is my second attempt. Sorry if you already read this before.]
> 
> I am a developing a Groovy DSL to create Dockerfiles
> 
> The format of a Dockerfile looks like:
> 
> INSTRUCTION arguments
> 
> Instructions are case-insensitive but convention is for them to be UPPERCASE.
> 
> However Groovy doesn't seem to support optional parentheses if the method name is all uppercase:
> 
> def FOOBAR(String msg) {
> println msg
> }
> FOOBAR "hello"
> 
> groovyc: unexpected token: hello @ line 2, column 8.
> FOOBAR "hello"
> ^
> 
> Do you know of any way to get this to work or is this a known limitation of Groovy?
> 
> I tried with Groovy version 2.4.5
> 
> If anyone has any insight, it would be very helpful.
> 
> /matthias 
> 
> -- 
> Matthias Grüter
> www.grueter.name <http://www.grueter.name/>   //   matthias@grueter.name <ma...@grueter.name>