Hacker News new | ask | show | jobs
by delackner 5539 days ago
Only part way through that article you linked to, but it is fascinating. The part that includes Moore's rant against local variables crystallized an idea that had been bubbling around in my subconscious for some time. Very often the only reason I find I am writing a local variable is to make an expression with several sub-parts easier to see the sub-expression values in gdb. This wouldn't be quite so necessary if the debugger had a syntax for saying "list the sub expressions of this statement" and for saying "print sub-expression #N". For instance, with the debugger stopped just before a line like x = foo(bar(a,b), blat(c,d)); "list subs" -> "0: bar(a,b), 0.1: a, 0.2: b, 1: blat(c,d), 1.1: c, 2.1: d." then just typing something like sub0 would print the value of bar(a,b)."

Of course lacking such a facility I just end up scattering extra locals even though I end up feeling like the output is rather archaic. a = ...; b = ...; c = f(a,b);