[#10492] Ruby 1.8.6 preview3 has been released — "Akinori MUSHA" <knu@...>

Hi,

26 messages 2007/03/04
[#10500] Re: Ruby 1.8.6 preview3 has been released — Hugh Sasse <hgs@...> 2007/03/05

On Mon, 5 Mar 2007, Akinori MUSHA wrote:

[#10507] Dynamic Array#join with block — <noreply@...>

Patches item #9055, was opened at 2007-03-05 19:57

12 messages 2007/03/05
[#10520] Re: [ ruby-Patches-9055 ] Dynamic Array#join with block — Nobuyoshi Nakada <nobu@...> 2007/03/06

Hi,

[#10594] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org>

In ext/thread/thread.c, remove_one leaves the list in an inconsistent state.

15 messages 2007/03/14
[#10596] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 00:15:57 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10597] Re: [PATCH] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/14

> > The fix is in thread-mutex-remove_one.diff.

[#10598] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 01:19:04 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10599] Re: [PATCH] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/14

On Wednesday 14 March 2007 17:29, MenTaLguY wrote:

[#10600] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 01:48:42 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10615] Multiton in standard library — TRANS <transfire@...>

Hi--

16 messages 2007/03/15
[#10619] Re: Multiton in standard library — Tom Pollard <tomp@...> 2007/03/16

[#10620] Re: Multiton in standard library — TRANS <transfire@...> 2007/03/16

On 3/15/07, Tom Pollard <tomp@earthlink.net> wrote:

[#10646] Marshal.dump shouldn't complain about singletons if the _dump method is defined — <noreply@...>

Bugs item #9376, was opened at 2007-03-19 15:58

12 messages 2007/03/19
[#10647] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Urabe Shyouhei <shyouhei@...> 2007/03/19

noreply@rubyforge.org wrote:

[#10648] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/19

On Monday 19 March 2007 18:01, Urabe Shyouhei wrote:

[#10651] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Yukihiro Matsumoto <matz@...> 2007/03/19

Hi,

[#10665] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — "Chris Carter" <cdcarter@...> 2007/03/20

On 3/19/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#10712] Ruby Method Signatures (was Re: Multiton in standard library) — "Rick DeNatale" <rick.denatale@...>

On 3/19/07, TRANS <transfire@gmail.com> wrote:

10 messages 2007/03/21
[#10715] Re: Ruby Method Signatures (was Re: Multiton in standard library) — Jos Backus <jos@...> 2007/03/22

On 3/19/07, TRANS <transfire@gmail.com> wrote:

[#10798] Virtual classes and 'real' classes -- why? — "John Lam (CLR)" <jflam@...>

I was wondering if someone could help me understand why there's a parallel =

12 messages 2007/03/28
[#10799] Re: Virtual classes and 'real' classes -- why? — MenTaLguY <mental@...> 2007/03/28

On Thu, 29 Mar 2007 04:44:16 +0900, "John Lam (CLR)" <jflam@microsoft.com> wrote:

[ ruby-Bugs-9488 ] Date module, step method, infinite loop if +step+ is 0 ?

From: <noreply@...>
Date: 2007-03-23 11:02:51 UTC
List: ruby-core #10752
Bugs item #9488, was opened at 2007-03-23 11:02
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=9488&group_id=426

Category: Standard Library
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Colin Bartlett (colinb2)
Assigned to: Nobody (None)
Summary: Date module, step method, infinite loop if +step+ is 0 ?

Initial Comment:
My apologies in advance if this is known about.
I have looked at the outstanding "bugs" list,
and couldn't find anything.

I'm using the standard Ruby Installer for Windows
Ruby Version 1.8.5, Installer Version 185-21
ruby --version  ->  ruby 1.8.5 (2006-08-25) [i386-mswin32]

code of the step method in Tadayoshi Funaba's Date module
  # Step the current date forward +step+ days at a
  # time (or backward, if +step+ is negative) until
  # we reach +limit+ (inclusive), yielding the resultant
  # date at each step.
def step(limit, step)  # :yield: date
  da = self
  op = [:-,:<=,:>=][step<=>0]
  while da.__send__(op, limit)
    yield da
    da += step
  end
  self
end

Comment: the step method seems to go into an infinite loop
if +step+ is 0, continually yielding the start date (self).
I didn't instantly understand the "op = " and "while" lines,
but I think I understand them now, except if +step+ is 0
then the while expression becomes  ( da - limit ),
which is always going to be True because even if it's 0
it will be True? Is that why the infinite loop is happening?

Is an infinite loop the intended behaviour if +step+ is 0 ?
Or is the intention for people to rely on testing 
not to use a +step+ of 0? (That's not intended 
to be sarcastic: I don't know enough to be sure
the behaviour is not as intended.)

In the Integer step method a +step+ of 0 raises an exception,
which seems a better way to handle it? (Maybe have an option
of yielding (only once) the start date if +step+ is 0 ?
On reflection I think I still prefer the Integer step behaviour.)


 # The following is code to show the different behaviour
 # of Integer step and Date step when +step+ is 0.

$\ = "  " ; $, = "  "  # helps print output legibly on single lines

puts "\n ** Integer step example: exception raised if step = 0"
500.step( 505, 2 )  { | nxt |  print nxt }  # ->  500  502  504
50.step( 45, -2 )  { | nxt |  print nxt }  # ->  50  48  46
begin
  5.step( 5, 0 )  { | nxt |  puts nxt }
rescue 
  puts ' * exception raised: message = ' + $!.message
end  # ->   * exception raised: message = step can't be 0

require 'date'
c = Date.new( 2008, 1, 31 )
puts "\n\n ** Date step example:" + 
          " no error if step = 0, but an infinite loop?"
c.step( c + 3, 2 )   { | nxt |  print nxt }
                   # ->  2008-01-31  2008-02-02
c.step( c - 3, -2 )  { | nxt |  print nxt }
                   # ->  2008-01-31  2008-01-29
puts
count = 0
c.step( c + 3, 0 ) { | nxt |
                     puts count.to_s + ": " + nxt.to_s
                     count += 1
                     break if count > 10
                   }  # -> "infinite" loop of 2008-01-31 ?


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=9488&group_id=426

In This Thread

Prev Next