Function calls

retard re at tard.com.invalid
Thu Jan 28 05:58:27 PST 2010


Wed, 27 Jan 2010 18:34:57 +0100, Pelle Månsson wrote:

> I disagree, I find the function calls without the () to be really
> prettifying.
> 
> But maybe that's just me.
> 
> I don't think that it causes serious bugs, you would see that it's an
> integer the moment you try and use it. It also helps changing code
> from/to functions.
> 
> I really like this feature, and would miss it should it go away.

I just can't understand why implementing the optional ()s can be so hard. 
Scala does it and as far as I know, the solution doesn't have any 
problems. They also solved the property issues. In scala property methods 
have special names to distinguish them.

object foo { def prop = 42; def prop_=(a: Int) = println(a) }
defined module foo

scala> foo.prop = 42
42

scala> object foo { def prop = 42; def prop_=(a: Int) = println(a) }
defined module foo

scala> foo.prop
res12: Int = 42

scala> foo.prop()
<console>:6: error: foo.prop of type Int does not take parameters
       foo.prop()
               ^

scala> foo.prop = 42
42

scala> foo.prop(42)
<console>:6: error: foo.prop of type Int does not take parameters
       foo.prop(42)
               ^

scala> foo.prop_(42)
<console>:6: error: value prop_ is not a member of object foo
       foo.prop_(42)
           ^

scala> foo.prop_=(42)
42

scala> foo.prop += 1
43



More information about the Digitalmars-d mailing list