News for hackers. Stuff that matters.
Re:Golang landmines by Vendan on Saturday September 17, 2016 @09:31PM (#12523483)
People coming from highly dynamic languages, like python and such, most likely
Re:Golang landmines by enneff on Saturday September 17, 2016 @09:38PM (#12523504)
How would this make any sense, though? In the case of "range" I can see the confusion, but when you explicitly declare a variable and increment it for each iteration of the loop, the only way it can work is if there's one instance of the variable.
Re:Golang landmines by zamalek on Sunday September 18, 2016 @01:54AM (#12524116)
It's the disparity between how a human thinks and how a machine thinks. Systems languages tend to care less about humans think, which I prefer because humans don't have consistently defined logic.
Re:Golang landmines by enneff on Sunday September 18, 2016 @04:00AM (#12524375)
I don't think so. As programmers, we have to think logically, and in this situation there really is no other logical way of thinking about how that code might work.
Re:Golang landmines by pjmlp on Sunday September 18, 2016 @01:48PM (#12526253)
Only C and its direct descendants.

There are saner alternatives, more human friendly, to systems programming.

Re:Golang landmines by teraflop on Saturday September 17, 2016 @10:15PM (#12523596)
Python's behavior is the same as Go's. For example, this code:

    l = []
    for i in xrange(3):
      l.append(lambda: i)
    print [f() for f in l]
prints [2, 2, 2].
Re:Golang landmines by loevborg on Sunday September 18, 2016 @05:48AM (#12524632)
Same in javascript:

    var fns=[];
    for (var i=0; i<3; i++) {
       fns.push(function(){return i});
    };
    fns.map(function(x) { return x.call(); });
Returns

    [ 3, 3, 3 ]