[ nice-Bugs-874594 ] local methods ()

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.lang.nice.devel
Message-ID <[email protected]>
Bugs item #874594, was opened at 2004-01-10 21:23
Message generated for change (Comment added) made by bonniot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=874594&group_id=12788

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Isaac Gouy (igouy)
Assigned to: Nobody/Anonymous (nobody)
Summary: local methods ()

Initial Comment:
void main(String[] args){
   void f1(){ println("f1"); }
   void f2(){ println("f2"); }

   f1();
   f2;
   println("Again!");
   f1;
   f2();
}


\Nice\Test>java -jar t.jar
f1
Again!
f2


Nice compiler version 0.9.6 prerelease (build 2004.01.10, 
17:42:12 UTC)

----------------------------------------------------------------------

>Comment By: Daniel Bonniot (bonniot)
Date: 2004-01-15 17:57

Message:
Logged In: YES 
user_id=88952

Sorry if I was not clear, but be reinsured, I have no
intention to do that. An expression of the form 'x.y' is
always a "call", so the brackets are optional when there are
no arguments besides x.

The only change we are considering is to make the parser
discover the cases where an expression without side effects
(like getting a reference to a function) is used as a
statement, which makes it useless, and most likely reveals a
bug.


----------------------------------------------------------------------

Comment By: Isaac Gouy (igouy)
Date: 2004-01-15 17:26

Message:
Logged In: YES 
user_id=536291

>difficult and inconsistent to
>allow brackets to be omitted in a call

So we're saying that instead of the current situation where 
we can have 
   obj.getClass.getName 

we would in all cases (class methods, method local methods, 
top level methods) we would need to write like
   obj.getClass().getName()

----------------------------------------------------------------------

Comment By: Daniel Bonniot (bonniot)
Date: 2004-01-15 15:39

Message:
Logged In: YES 
user_id=88952

Brackets are required to make a call. It's completely
consistent.

  f2;

is currently parsed an a reference to f2, which is simply
ignored. If that does not cause problem, it should probably
not be accepted at all.

As Isaac says, it would be difficult and inconsistent to
allow brackets to be omitted in a call, so I don't think we
should do it.


----------------------------------------------------------------------

Comment By: Isaac Gouy (igouy)
Date: 2004-01-11 04:30

Message:
Logged In: YES 
user_id=536291

(I guess the example I gave was module functions not local 
functions, although the same thing happens with functions 
that are local to a method.)

Yes, there seems to be some interface between having 'first 
class functions' and allowing the convenience of not needing 
() for a method invocation.

If 
   int f() = 5;
   int i = f;
then how would we assign the function to a variable?
   void->int fun = f;


Of course, the same thing crops up for calls to Java static 
methods:

import java.text.*;
void main(String[] args){
   let m = NumberFormat.getAvailableLocales;
   println(m);
}

I like the convenience of not needing to use () but I like 
consistency more. It would be nice if the way a function was 
invoked was clearly different from the way a functional was 
referenced. (Maybe I just don't understand how to do that.)



----------------------------------------------------------------------

Comment By: Arjan Boeijink (arjanb)
Date: 2004-01-11 00:59

Message:
Logged In: YES 
user_id=688815

This is a bug but i'm not sure whether this code should just 
work or throw an error/warning becauce the () are missing.

When leaving () away is possible and what it means should be 
discussed because the exact rules for this are not known and 
I don't think the current implementation is consistent.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=874594&group_id=12788


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.