On Tue, 19 Jul 2005, Berger, Daniel wrote:

>> -----Original Message-----
>> From: Ryan Leavengood [mailto:mrcode / netrox.net]
>> Sent: Monday, July 18, 2005 9:58 AM
>> To: ruby-talk ML
>> Subject: Re: ruby-dev summary 26385-26467
>>
>>
>> Berger, Daniel said:
>>>
>>> What about simply altering String#to_a?
>>>
>>> String#to_a(bytes=false)
>>>    Returns the string as an array of characters, or bytes if the
>>> +bytes+ argument is true.
>>
>> I *strongly* dislike parameterizing methods like this. If you
>> are going to fundamentally alter the behavior of a method,
>> just make a new method. That way the new behavior is explicit.
>>
>> If I read this code:
>>
>> "str".to_a(true)
>>
>> I will probably have to read the documentation for to_a to
>> figure out what the true means. Whereas this:
>>
>> "str".to_bytes # Or whatever it is called
>>
>> is essentially self-documenting.
>
> Generally speaking I agree with you, but I also try to weigh that
> consideration against API bloat.  And, since the default (false) is
> probably what most people would use most of the time, it's a bullet I'd
> be willing to bite.  However, all of this probably academic, as you
> mention below.


you can always have the best of both worlds with something like

   "string".to_a 'bytes' => true

the beauty of this sort of api is that later you can add

   "string".to_a 'bytes' => true, 'unicode' => true

and break nothing.

cheers.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple.  My religion is kindness.
| --Tenzin Gyatso
===============================================================================