4 ms·
People coming from highly dynamic languages, like python and such, most likely
by Vendan 10y ago
People coming from highly dynamic languages, like python and such, most likely
- enneff 10y agoHow 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.
- zamalek 10y agoIt'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.
- enneff 10y agoI 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.
- pjmlp 10y agoOnly C and its direct descendants. There are saner alternatives, more human friendly, to systems programming.
- teraflop 10y agoPython'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].
- loevborg 10y agoSame 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 ]