Gavin Sinclair
9/26/2003 4:43:00 PM
On Saturday, September 27, 2003, 2:10:42 AM, Austin wrote:
> On Sat, 27 Sep 2003 00:05:48 +0900, Martin DeMello wrote:
>> Gavin Sinclair <gsinclair@soyabean.com.au> wrote:
>>> PS. I am launching a project that consolidates popular extensions to
>>> the standard classes. Look at project "extensions" on RubyForge if
>>> you''re interested. The CVS will hopefully be there within 7 days. A
>>> release will be a few more weeks. This is inspired by that nagging
>>> feeling. Instead of implementing common modifications in my code, I can
>>> rely on a reference implementation that is documented and tested.
>> Excellent idea. Two questions, though - how do you define popularity, and
>> how do you avoid bloat?
> I can think of two things that should be there: #map_with_index and number
> formatting, since they appear every so often. Other examples exist, I am
> sure, but seeing what extensions are listed on the RubyGarden wiki would be
> a good start.
#map_with_index is there now. Well, on my computer anyway.
> IMO, the way to avoid bloat is like this:
> ext.rb # loads everything
> ext/numeric
> ext/numeric.rb # loads all extensions to Numeric classes
> ext/numeric/format.rb
> ext/enumerable
> ext/enumerable.rb # loads all extensions to Enumerable
> ext/enumerable/map.rb
> The file ext/numeric/format.rb could contain the number formatting routine I
> wrote and is currently on the RubyGarden wiki. If there are other numeric
> formatting routines, they could be put there as well. The file
> ext/enumerable/map.rb could contain #map_with_index.
> What do you think?
> -austin
What I have chosen is:
require "extensions/all" # everything
require "extensions/enumerable"
require "extensions/io"
require "extensions/string"
Since these deal exclusively with modifications to core classes, it
makes sense to me that the things you load should be named after them.
It doesn''t make sense to me that finer granularity is required,
because: (a) it''s too much to remember and too much hassle to look up;
and (b) the extensions shouldn''t be so numerous as to require it.
However, you are the second person to propose what you did, so I''ll
have to give it some thought.
BTW, the extension package is conservative. If an intended method
already exists, it emits a warning and doesn''t overwrite the
method. Also, an exception is thrown if a method is claimed to be
implemented but isn''t.
Gavin