On Tue, 22 Jul 2008, Robert Dober wrote:

> On Mon, Jul 21, 2008 at 5:18 PM, David A. Black <dblack / rubypal.com> wrote:
> <snip>
>> I'm afraid I don't follow that at all. What does it have to do with
>> other ! methods?
> Well I interpreted your statement as follows:
> dup is a bad name for Symbol or NilClass as it does not really create
> a new symbol or nil
> thus I call it dup!
> By extension that would mean that e.g.
> gsub! is called gsub! because it does not really gsub
>
> Did I read you incorrectly so far?

Yes. There's no general "___ does not really ___" rule. The only
general rule about ! methods is the idea of "danger", which can take
many forms.

> There is already some disagreement about the ! suffix so far, your new
> interpretation of ! meaning dangerous

It's absolutely not new; Matz has always characterized it that way
("dangerous").

> in the sense that it does something slightly different of what might
> be expected might add to the confusion of
> what ! should mean.
> IMHO it should mean a modifying version of a non modifying version of
> a method. But there is not much agreement on this :(.

There's been a lot of misunderstanding and second-guessing of Matz,
but he's always been consistent in his description.

> However there seems agreement that xxx! is a more "dangerous" version
> of xxx and in our case there would
> be dup! but no dup for e.g. NilClass.
>
> Are there other classes, modules, singletons with an xxx! without an
> xxx <space> ?

No; ! methods only make sense in pairs with non-! methods. See my blog
post (cited earlier). Unfortunately, there's a trend toward sticking !
on methods that aren't in pairs. It makes it meaningless.

Must go -- my students are back from lunch :-)


David

-- 
Rails training from David A. Black and Ruby Power and Light:
     Intro to Ruby on Rails  July 21-24      Edison, NJ
  *  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!