Fantom

Login | Register

Allow () operator to be used on func fields #895

jessevdam
3 Jan 2010

I started using Fantom and found a title bug. Maybe you remember me from the early days of NF ax. It is a nice language, I must say the scope thing in fantom is a superb feature.

Here is the thing I found.

class SomeClass {

|XElem node -> Bool| ftemp;

new make(|XElem node -> Bool| ftemp)
{
  this.ftemp = ftemp;
}

override Void check(XElem node)
{
 //If have to add this line to make it work otherwise I get the error
 // "Expected method, not field 'Test_0::PassTest.ftemp'"
 |XElem node -> Bool| ftemp := this.ftemp;
 if(ftemp(node))
    System.out.printLine(node);
}

}

I was using version 1.0.47

brian
4 Jan 2010

Hi Jesse,

The way the compiler currently works is that you are required to use parens to show your intent to first get the field, then call it like a method:

funcField(args)     // error
(funcField)(args)   // ok

Sometimes I find that rather annoying myself. Allowing a func field to be called like a method might actually be a better design.

Let's make it an official proposal: if a field is typed as a func, then you can call it like a method. That would obey Bertrand Meyer's uniform access principle better.

Comments?

katox
4 Jan 2010

+1 on that. I think this will also get rid of confusing func()(realArg1, realArg2).

KevinKelley
4 Jan 2010

+1!

brian
4 Jan 2010

I think this will also get rid of confusing func()(realArg1, realArg2).

If the slot is a method, that will still be required, because the first set of () bind as the methods arguments.

qualidafial
5 Jan 2010

+1 from me too

lbertrand
5 Jan 2010

+1 - like the simplification

brian
5 Jan 2010

Promoted to ticket #895 and assigned to brian

I will make field() call the func if the field is declared as a Func.

There will be no changes to how methods which return functions work (which includes fields that override methods).

qualidafial
6 Jul 2010

ping

brian
7 Jul 2010

Renamed from Scope as field is not detected as function to Allow () operator to be used on func fields

brian
7 Jul 2010

Ticket resolved in 1.0.54

Its done!

Login or Register to Reply

Back | All Topics