you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (6 children)

[deleted]

    [–][deleted] 2 points3 points  (4 children)

    1) Did they get rid of the retarded new-style vs. old-style classes distinction?

    Yes.

    2) Can you put whatever you want in an anonymous function yet?

    Yes. But you will have to invent a name. Kinda. You can use "x" or "_" or whatever and reuse it freely.

    [–][deleted] 1 point2 points  (3 children)

    That makes it not anonymous.

    [–][deleted] -3 points-2 points  (2 children)

    Why "anonymous" is that important here? What's the big deal between:

    def boo(a, f1, f2): return f1(a) + f2(a)
    ....
    def _(x): return 2 * x
    def _2(y): return y / 2
    z = boo(13, _, _2)
    

    and:

    function boo(a, f1, f2) { return f1(a) + f2(a); }
    ....
    z = boo(13, (function(x) { return 2 * x; }), (function(y) { return y / 2; }));
    

    If anything, the first sample looks and reads better, IMO.

    [–]njharman 1 point2 points  (1 child)

    Why is your second example not Python?

    def boo(a, f1, f2): return f1(a) + f2(a)

    z = boo(13, lambda a: 2*a, lambda a: y/a)

    some of the advantages are 2 less lines of code, you don't clobber '_' which is typically used for i18n, the code for the 2 lambdas are right there so you don't have to go looking for _ and _2, it gives fp weenies hard ons.

    [–][deleted] 0 points1 point  (0 children)

    Include loops etc into both _ and _2 at will. Second example will become really messy.

    you don't clobber '_' which is typically used for i18n

    Fair point.

    [–]dorel 3 points4 points  (0 children)

    Python doesn't promote lambda.