Hi --

On Tue, 10 Oct 2006, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to"
>    on Tue, 10 Oct 2006 01:56:17 +0900, dblack / wobblini.net writes:
>
> |I like to_list.  It's specific enough that misuse/overuse will be
> |evident.  And even though "list" isn't a core class, it's a noun and
> |also much more meaningful than "splat".
>
> Well, that name assumes we are converting an object into a list which
> in reality an array.

I'm thinking of a list as a kind of unwrapped array.  So, for example:

   Hash[1,2,3,4]     # a list of four numbers -- no array involved
   Hash[*[1,2,3,4]]  # an array originally, but unarrayed into
                     #   a list of numbers

> Besides that calling parameters a list reminds me Perl too much.
> Now I understand how Matju felt in the original post. ;-)
>
> How about to_values?  It's noun; plurality indicates it's a collection
> of values (which often represented by an array).  to_args comes next
> in my preference list.

The possible problem with to_values is that it suggests that what was
there before the conversion was *not* values, which I think might be
misleading.  to_args still seems too specific to me -- for example, in
this:

   [*0...10]

there's nothing arg-related about what's happening to the range.

I also have a question about the use of this method.  Do you think it
would always be defined in terms of the * itself?  In other words:

   class C
     def initialize(a)
       @array = a
     end
     def to_values
       *a
     end
   end

But then wouldn't it just return an array?  Or would the * still
un-array it?

   c = C.new([1,2,3,4])
   Hash[*c]             # == Hash[1,2,3,4] ?

But then... why have a separate definition?  I'm sure there's a reason
-- I'm just not yet seeing how one would use it.


David

-- 
                   David A. Black | dblack / wobblini.net
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org