groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Winnebeck, Jason" <Jason.Winneb...@windstream.com>
Subject RE: Optional parentheses for methods with all uppercase names
Date Mon, 29 Feb 2016 13:57:18 GMT
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 <batuhanbayrakci@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.

Mime
View raw message