News for hackers. Stuff that matters.
Re:Tips for naming variables by bkudria on Wednesday May 13, 2009 @03:36PM (#607483)
Um, have you ever written code like this in a real program? Honestly? Why would you ever want to swap variables?

(I mean, I remember doing this thing in TI-83+ BASIC, where valid variable names were limited to the letters of the alphabet ...)

Re:Tips for naming variables by mojuba on Wednesday May 13, 2009 @04:42PM (#607596)
Check out some popular sorting algorithms, those that do the job "in place", i.e. without additional memory allocation.
Re:Tips for naming variables by bkudria on Thursday May 14, 2009 @03:51AM (#608399)
Yes... but how many times have you re-written a sort? (Where 'you' is your average programmer, or, even, the above-average programmer who reads technical blogs and toward whom this post is targeted)
Re:Tips for naming variables by mojuba on Thursday May 14, 2009 @10:05AM (#608747)
If you are an inventor of sorting algorithms, I'd guess you do that quite often.

But seriously, does it really matter? Short functions or blocks with variables of local significance do exist. Swap() was just the first thing that popped up, probably because I like messing around with algorithms and re-implementing them. Which every self-respecting programmer, umm, should do, I think.

Re:Tips for naming variables by wlievens on Friday May 15, 2009 @04:14AM (#610248)
Most projects contain at least a handful of utility functions that your base library doesn't offer. These utility functions are largely independent of the problem domain, and often of a mathematical nature. Therefore, short, undescriptive variable names (such as 'x') are perfectly acceptable.