------art_27917_31239652.1201887288651
Content-Type: text/plain; charset=WINDOWS-1252
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I agree that <=> should only compare two temporal objects of the same class,
which is how the method is currently constructed. My patch for a Temporal
mixin:

http://www.ruby-forum.com/topic/139881#622989

which is currently being considered for inclusion into the Ruby core, allows
developers to write code which reinforces this constraint on comparisons by
using the more domain-specific terms "before" and "after" to compare Times,
Dates, etc. For example, it's conceivable a developer might attempt

some_time <=> 10039483

but they would certainly be much less likely to try

some_time.before? 10039483

because the vocabulary more precisely describes what the program is doing.

That being said,

+1 for Vladimir's patch.

On Feb 1, 2008 9:09 AM, Vladimir Sizikov <vsizikov / gmail.com> wrote:

> Hi,
>
> Currently (in both, MRI 1.8.6 and 1.9) the docs for Time#<=> state
> that the Time object can
> be compared with Numeric argument:
>
> "Differenceͳeturns a new time that represents the difference between two
> times,
> or subtracts the given number of seconds in numeric from time."
>
> But this is not what the code does. The code compares only Time instances,
> and returns nil for everything else. I was able to dig up the history
> and it seems,
> that the change was intentional in rev. 3823, with comment:
> " time.c (time_cmp): does not compare with numbers for
>  interchangeability. (ruby-bugs-ja PR#458)"
>
> So it seems that the description should be updated to match the behavior.
>
> Here's the simple patch against 1.8 branch, but similar thing applies
> to trunk too.
>
> Thanks,
>  --Vladimir
>
> P.S. Can somebody tell me where can I find that ruby-bugs-ja PR#458
> online?
>

------art_27917_31239652.1201887288651
Content-Type: text/html; charset=WINDOWS-1252
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I agree that &lt;=&gt; should only compare two temporal objects of the same class, which is how the method is currently constructed. My patch for a Temporal mixin:<br><br>http://www.ruby-forum.com/topic/139881#622989<br>
<br>which is currently being considered for inclusion into the Ruby core, allows developers to write code which reinforces this constraint on comparisons by using the more domain-specific terms &quot;before&quot; and &quot;after&quot; to compare Times, Dates, etc. For example, it&#39;s conceivable aeveloper might attempt<br>
<br>some_time &lt;=&gt; 10039483<br><br>but they would certainly be much less likely to try<br><br>some_time.before? 10039483<br><br>because the vocabulary more precisely describes what the program is doing.<br><br>That being said,<br>
<br>+1 for Vladimir&#39;s patch.<br><br><div class="gmail_quote">On Feb 1, 2008 9:09 AM, Vladimir Sizikov &lt;vsizikov / gmail.com&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>Currently (in both, MRI 1.8.6 and 1.9) the docs for Time#&lt;=&gt; state<br>that the Time object can<br>be compared with Numeric argument:<br><br>&quot;Differenceͳeturns a new time that represents the difference between two times,<br>
or subtracts the given number of seconds in numeric from time.&quot;<br><br>But this is not what the code does. The code compares only Time instances,<br>and returns nil for everything else. I was able to dig up the history<br>
and it seems,<br>that the change was intentional in rev. 3823, with comment:<br>&quot; time.c (time_cmp): does not compare with numbers for<br> &nbsp;interchangeability. (ruby-bugs-ja PR#458)&quot;<br><br>So it seems that theescription should be updated to match the behavior.<br>
<br>Here&#39;s the simple patch against 1.8 branch, but similar thing applies<br>to trunk too.<br><br>Thanks,<br><font color="#888888"> &nbsp;--Vladimir<br></font><br>P.S. Can somebody tell me where can I find that ruby-bugs-ja PR#458 online?<br>
</blockquote></div><br>

------art_27917_31239652.1201887288651--