On Jun 14, 2006, at 4:09 AM, Mislav Marohnić wrote:

On 6/14/06, Jamie Quint <[EMAIL PROTECTED]> wrote:
I think the alias idea is a good one. I have submitted a patch that
does exactly that.

http://dev.rubyonrails.org/ticket/5387

Jamie,

Your patch has one fundamental flaw. Purists who would want to use kibibyte etc. to display sizes measured in base 2 units would sure be against kilobyte etc. measuring in base 2 units too. In other words, this is only half of the solution, and we are looking for a complete one.

James: about drop-kicking the principle of least surprise - in my opinion, programmers who would be surprised to find out 'kilo' means 1000 are the same who don't exactly care about the precision. So I don't think they are even going to notice.

About the potential breakage: in my patch, there is a method (ActiveSupport::CoreExtensions::Numeric::Bytes.legacy_base) which makes good ol' methods measure in base 2 units again. Folk who don't want to roll with this change would put that in environment.rb, preventing breakage.

About writing a plugin for this: sure I'm going to make a plugin out of my patch; I just need to set up a repository for this. But I never believed this was just some odd, wacky practice intented for rare people -- I believe this should be Rails core to raise awareness in current and (especially) next generations. Today, precision matters; Strongspace, some bittorent clients and trackers, and others all demonstrate this.

Note that Strongspace and bittorent *display* the number as KiB, etc. You can still do that in Rails--the Numeric#kilobyte method is for programmers to call--it's up to you to tell the user what the units are. Thus, there is nothing preventing you from saying, in a view:

  <%= size.kilobytes %> KiB

But that's not the issue that started all of this. What is under discussion right now is not displaying the "proper" units to the user, it is making a helper with with the "proper" name available to the developer.

That said, the half-solution is sufficient. Is it necessary? I still have my doubts. For now, a plugin is the way to go. If it gains wide enough adoption, we can certainly consider adding to core.

- Jamis_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to