Re: Object or <T> parameters

[email protected] Wed, 25 Feb 2004 17:29:06 -0600
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
I think it is too bad that we spend so much time discussing syntax here. Now I
am starting to appreciate how hard it is to come up with a nice syntax that is
consistent.

Quoting Bryn Keller <[email protected]>:
> So noted. I agree it's easier than one might like to make a mistake and 
> pass the method where you wanted the result of calling the method. This 
> is common to most languages with first-class methods, of course. Some 
> make you use some special character to indicate that you want the 
> method, and not the call: \foo, :foo, or something like that. What do 
> you think of that approach?

That is reasonable. It seems kind of ugly since I've not used languages that do
that. 

Here is another example to consider. Notice that "a.x" is equivalent to "a.x()"
but "z" is not equivalent to "z()".  This could be confusing to somebody trying
to understand functions as values with the current syntax.

Also notice that:
     (A -> int) h = y;
is allowed but:
     (A -> int) i = x;
is not allowed, although you can use "x" and "y" with the same syntaxes in every
other situation. That is maybe a bug in the compiler?

    package examples;

    class A { int x; }

    int y(A a) = 2;

    int z() = 3;

    void main(String [] args) {
        let a = new A ( x: 1 );
        int b = a.x;
        int c = a.x();
        int d = x(a);

        int e = a.y;
        int f = a.y();
        int g = y(a);

        (A -> int) h = y;
        // error: You must supply the object
        //        that contains this field
        (A -> int) i = x;
    }

Regards,
Brian





-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click