News for hackers. Stuff that matters.
Re:The worst thing about CoffeeScript by tghw on Saturday January 25, 2014 @01:13PM (#7121616)
The worst thing about CoffeeScript is that you are used to having scoping work a different way?

Let's extend your example:

    >>> a = 1
    >>> def foo():
          print a
    >>> foo()
    1
So Python does take from the outer scope?

    >>> a = 1
    >>> def foo():
          a = 2
          print a
    >>> foo()
    2
Or not?

    >>> a = 1
    >>> def foo():
          print a
          a = 2
    >>> foo()
    UnboundLocalError: local variable 'a' referenced before assignment
Or it just doesn't work at all?

Next time, pick a better example. The answer to "What does Python do with a variable from outside a function's scope?" is "It depends."

At least CoffeeScript is consistent.

Re:The worst thing about CoffeeScript by emn13 on Saturday January 25, 2014 @02:31PM (#7121972)
Coffeescript isn't consistent.

    setter = (arg) -> store = arg
    store = 'initial'
is quite different from

    store = 'initial'
    setter = (arg) -> store = arg
This is a practical problem since it means that the most commonly used JS encapsulation feature - closures - become harder to write. Suddenly assignments that have no direct influence on each other cannot be blindly reordered (which is a pain), and in particular closures that have a bunch of helper functions defined initially that need to ensure that local variables are set before the helpers, even if those local variables are themselves functions.

It's just a mess. Frankly, I think javascript does this part a lot better than coffeescript, especially now that "use strict" exists and you can get some feedback when your scoping assumptions turn out wrong, rather than a silent failure and unexpected behavior.

Re:The worst thing about CoffeeScript by aaron-lebo on Saturday January 25, 2014 @01:26PM (#7121682)
It is a bigger issue than lack of familiarity.

It can lead to some really unexpected bugs. There is a reason most languages don't do things this way.

http://lucumr.pocoo.org/2011/12/22/implicit-scoping-in-coffe...

Re:The worst thing about CoffeeScript by wildgift on Saturday January 25, 2014 @04:23PM (#7122504)
This is also a problem with javascript. Javascript should do automatic variable shadowing but also throw a warning.
Re:The worst thing about CoffeeScript by coldtea on Saturday January 25, 2014 @03:37PM (#7122285)
>The worst thing about CoffeeScript is that you are used to having scoping work a different way?

No, the issue is that he's used to having scoping work properly.

Coffeescript behavior corrects a wrong (shadowing) with an even worse wrong. Even worse, as a default it can affect variables outside of the function, so it breaks locality.

Re:The worst thing about CoffeeScript by mattdeboard on Sunday January 26, 2014 @09:48PM (#7128431)
I suspect, but don't know, this is different in Python 3, since `print a` changes from a statement to an expression.