From: dagbrown@... (Dave Brown) Date: 2003-09-16T04:48:29+09:00 Subject: Re: performance and style advice requested In article , Alex Martelli wrote: : Ben Giddings wrote: : : > Some style advice: : > : > On Sunday, September 14, 2003, at 12:44 PM, Alex Martelli wrote: : >> # : >> # factorial, memoized via an Array : >> # : >> $_fact_memo=[1,1,2,6,24,120,720] : > : > Ugh. This is what really bothers me about python programs. Ugly : > underscores. : : Heh -- matter of taste, I guess; what _I_ personally find ugly is : that leading $, and I left the underscores in to try to ameliorate : that. It just makes it worse. The $ is ugly for a reason--the use of global variables is discouraged. The Ruby Way to do it would be to put your combinatorial stuff into a module or a class and use class variables for your memoizing. : Of course, nothing stops you from moving to a camelCaseish : $factMemo -- however, not only do I personally find that less : readable, but I'd also like to leave a hint that the memo is an : internal implementation detail, not a feature meant for external : consumption, and I like the convention of a leading _ for that. I prefer the convention of putting it into a class where it belongs. :-) : (Of course, I _could_ wrap up the fact function and its memo in : a single package in any of various ways, I'm sure, so the "hint" : aspect is quite secondary). One of the philosophies of Ruby is that there's no need to drop hints when you can make things obvious--to both the compiler and to other programmers. --Dave