[#18121] [Ruby 1.8.7 - Bug #405] (Open) ssl.rb:31: [BUG] Bus Error — Anonymous <redmine@...>

Issue #405 has been reported by Anonymous.

14 messages 2008/08/04

[#18130] Re: New array methods cycle, choice, shuffle (plus bug in cycle) — Brian Candler <B.Candler@...>

> Seriously though... Array.first is a noun.

10 messages 2008/08/05

[#18319] NEW Command: absolute_path() -- — "C.E. Thornton" <admin@...>

Core,

14 messages 2008/08/16
[#18321] Re: NEW Command: absolute_path() -- — Yukihiro Matsumoto <matz@...> 2008/08/18

Hi,

[#18381] [Bug #496] DRb.start_service(nil) is very slow — Hongli Lai <redmine@...>

Bug #496: DRb.start_service(nil) is very slow

11 messages 2008/08/25

[ruby-core:18199] Re: New array methods cycle, choice, shuffle (plus bug in cycle)

From: gdefty@...
Date: 2008-08-08 06:37:08 UTC
List: ruby-core #18199
Hi,

I think that the verb/noun difference IS at the
heart of it. It seems that a bang version of a
verb makes sense ('do something' vs 'do somthing
to the receiver') where a bang version of a noun
('this thing') does not.

I also thought a lot about Matz's response:

| Basic rule of bang methods for strings and
arrays are modifying
| receivers in-place instead of modifying the
copies, i.e. Array#sort
| returns an sorted (copied) array, whereas
Array#sort! sorts the
| receiver in-place. They does same thing, only
differs in targets.

| You Array#sample! does pick samples from array,
IN ADDITION TO
| removing picked elements from the receiver.
| Array#sample! does two things at once.

.. and what this seems to me to be saying is that
the bang has a very specific meaning. It is not
just about *changes* the receiver, but that the
receiver is *replaced by* that value which is
returned by the non-bang version.

graeme

---- Original Message ----

From: "David A. Black" <dblack@rubypal.com>
To: ruby-core@ruby-lang.org
Cc: 
Subject: [ruby-core:18176] Re: New array methods
cycle, choice, shuffle (plus bug in cycle)
Date: Fri, August 08, 2008, 05:45:00

Hi --

On Fri, 8 Aug 2008, David Flanagan wrote:

> David A. Black wrote:
>
>> I also agree with something I think you said
before, which is that
>> sample! as described here seems to be doing two
things. Usually the
>> "danger" of the bang fits very well with the
receiver-changing
>> behavior of arrays (plus the secondary danger
of the nil return). But
>> it's a stretch, I think, to think of a sampling
as a removal
>> operation. It feels a bit like having first!
remove the first element.
>
> I don't really get the objection to using a bang
in the name, though. While 
> its not strictly parallel, I can't see it
confusing anyone.  I'm replying to 
> David's comment about this, though, because when
I was trying to put together 
> an argument *for* sample!, I was going to use a
hypothetical first! as an 
> example: it seems to me that anyone who was
familiar with Ruby method naming 
> conventions would understand that first!, if it
existed, worked just like 
> shift.  first! and last! would certainly be
easier for new programmers who 
> haven't already been introduced to terms like
shift and pop.  (I'm not asking 
> to add these methods--just saying that they seem
perfectly reasonable to me!)

I don't see first and last as being just a ! away
from being
destructive. I wouldn't expect there to be a
destructive at! method
either. I think it has something to do with the
fact that these
methods don't do anything to the array in the
first place, so the leap
to doing that (nothing) destructively seems too great.

By contrast, all of the existing array bang
methods (sort!, reverse!,
collect!, compact!, reject!, map!, slice!,
flatten!, uniq!) all
perform transformations on the array, with the
possible except of
slice which sounds kind of destructive already.
Going from, say,
reversing a dup to reversing the object itself
seems like a smaller
and smoother step than going from referring to an
element to removing
that element permanently.

Come to think of it, they're all verbs, while
first, last, and at
aren't. That may be the heart of it.


David

-- 
Rails training from David A. Black and Ruby Power
and Light:
  *  Advancing With Rails    August 18-21   
Edison, NJ
  * Co-taught by D.A. Black and Erik Kastner
See http://www.rubypal.com for details and updates!




In This Thread

Prev Next