[#6864] ruby 1.8.4 rc breaks alias_method/rails in bad ways — "Ara.T.Howard" <ara.t.howard@...>

20 messages 2005/12/09
[#6870] Re: ruby 1.8.4 rc breaks alias_method/rails in bad ways — =?ISO-8859-15?Q?Florian_Gro=DF?= <florgro@...> 2005/12/12

Ara.T.Howard wrote:

[#6872] Re: ruby 1.8.4 rc breaks alias_method/rails in bad ways — ara.t.howard@... 2005/12/12

On Tue, 13 Dec 2005, [ISO-8859-15] Florian Growrote:

[#6873] Re: ruby 1.8.4 rc breaks alias_method/rails in bad ways — James Edward Gray II <james@...> 2005/12/12

On Dec 12, 2005, at 1:19 PM, ara.t.howard@noaa.gov wrote:

[#6874] Re: ruby 1.8.4 rc breaks alias_method/rails in bad ways — ara.t.howard@... 2005/12/12

On Tue, 13 Dec 2005, James Edward Gray II wrote:

[#6891] Time.utc! and Time.localtime! — Daniel Hobe <hobe@...>

Writing a script yesterday I found out, much to my surprise, that the

16 messages 2005/12/14

[#6918] change to yaml in 1.8.4 — ara.t.howard@...

14 messages 2005/12/16

[#6934] 1.8.x, YAML, and release management — Ryan Davis <ryand-ruby@...>

I'm concerned that 1.8.3's acceptance of non-backwards-compatible

28 messages 2005/12/18

[#6996] Problems building 1.8.4 with VS8 C++ Express Edition (cl 14.00) — Austin Ziegler <halostatue@...>

Visual Studio C++ 2005 Express Edition (VS 8.0)

20 messages 2005/12/27

Re: Time.utc! and Time.localtime!

From: dblack@...
Date: 2005-12-15 05:46:04 UTC
List: ruby-core #6898
Hi --

On Thu, 15 Dec 2005, Daniel Hobe wrote:

> I disagree that they are not really ! methods.  It changes the offset
> from utc, which I'm assuming is in a instance var or something.
> Because you are changing the receiver, I think it a solid candidate
> for changing to end in !
>
> A little background on the reason it bit me: I was displaying the time
> to the user (in puts time.localtime) and then thought I was saving the
> utc times to MySQL which doesn't save timezone. This broke when I went
> to read it out again and assumed everything was UTC.
>
> I suppose it could be put down to me not RTFM, but I think the
> behavior is surprising enough to warrant a change.

The thing is, ! doesn't mean that the method changes the receiver
(though a large number of ! methods do).  It means it's the more
"dangerous" of a pair of methods, of which there is also a non-!
version.  As Eric mentioned, they always come in pairs.  I don't think
there's such a thing as a method that ends in ! and has no non-!
counterpart.

There are lots of methods in Ruby that change the receiver without
ending in !.  For example, String#replace, which doesn't end in !
because then there would have to be a non-"dangerous" version of
"replacing" a string's content, and that doesn't make sense.

None of this means that utc should change the receiver -- just that
there's no mandate that it end in ! even if it does.


David

-- 
David A. Black
dblack@wobblini.net

"Ruby for Rails", forthcoming from Manning Publications, April 2006!

In This Thread