[#407] New feature for Ruby? — Clemens.Hintze@...
Hi all,
27 messages
1999/07/01
[#413] Re: New feature for Ruby?
— matz@... (Yukihiro Matsumoto)
1999/07/01
Hi Clemens,
[#416] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/01
On Thu, 01 Jul 1999, Yukihiro Matsumoto wrote:
[#418] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/01
Hi
[#426] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/02
Hi,
[#427] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/02
On Fri, 02 Jul 1999, you wrote:
[#428] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/03
Hi,
[#429] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/03
On Sat, 03 Jul 1999, you wrote:
[#430] Re: New feature for Ruby?
— gotoken@... (GOTO Kentaro)
1999/07/05
Hi,
[#431] Re: New feature for Ruby?
— Clemens Hintze <c.hintze@...>
1999/07/07
On Mon, 05 Jul 1999, you wrote:
[#440] Now another totally different ;-) — Clemens Hintze <c.hintze@...>
Hi,
21 messages
1999/07/09
[#441] Re: Now another totally different ;-)
— matz@... (Yukihiro Matsumoto)
1999/07/09
Hi,
[#442] Re: Now another totally different ;-)
— Clemens Hintze <c.hintze@...>
1999/07/09
On Fri, 09 Jul 1999, you wrote:
[#452] Re: Now another totally different ;-)
— gotoken@... (GOTO Kentaro)
1999/07/11
Hi,
[#462] Re: Now another totally different ;-)
— matz@... (Yukihiro Matsumoto)
1999/07/12
Hello, there.
[#464] Re: Now another totally different ;-)
— Clemens Hintze <c.hintze@...>
1999/07/12
On Mon, 12 Jul 1999, you wrote:
[#467] Re: Now another totally different ;-)
— matz@... (Yukihiro Matsumoto)
1999/07/12
Hi,
[#468] Re: Now another totally different ;-)
— gotoken@... (GOTO Kentaro)
1999/07/12
In message "[ruby-talk:00467] Re: Now another totally different ;-)"
[#443] — Michael Hohn <hohn@...>
Hello,
26 messages
1999/07/09
[#444] interactive ruby, debugger
— gotoken@... (GOTO Kentaro)
1999/07/09
Hi Michael,
[#448] Re: interactive ruby, debugger
— "NAKAMURA, Hiroshi" <nakahiro@...>
1999/07/10
Hi,
[#450] Re: interactive ruby, debugger
— Clemens Hintze <c.hintze@...>
1999/07/10
On Sat, 10 Jul 1999, you wrote:
[#490] Some questions concerning GC in Ruby extensions — Clemens Hintze <c.hintze@...>
Hi matz,
6 messages
1999/07/14
[#501] Ruby 1.3.5 — Yukihiro Matsumoto <matz@...>
Ruby 1.3.5 is out, check out:
1 message
1999/07/15
[#519] CGI.rb — "Michael Neumann" <neumann@...>
Hi...
7 messages
1999/07/24
[#526] Another way for this? And a new proposal! — Clemens Hintze <c.hintze@...>
Hi,
6 messages
1999/07/25
[ruby-talk:00456] Re: Now another totally different ;-)
From:
Clemens Hintze <c.hintze@...>
Date:
1999-07-11 10:16:55 UTC
List:
ruby-talk #456
On Sun, 11 Jul 1999, you wrote:
>Hi,
>
Hi too,
[...]
>But how we should treat Hash or String? Some Enumerable classes has
>its own []. For example, "abc"[1] != "abc".to_a[1].
Please don't take me wrong. If other classes need other behavior,
they simply overwrite the methods. A class can include
module Enumerable and so has a lot of methods available. But of
course if, for certain methods, it behaves other than Enumerable
would do it, it has to redefine/overwrite these methods!
But it could also use the other ones, defined by module Enumerable,
okay?
>
>
>By the way, Matz, why the following doesn't print "b\n" but 10?
>
>module Indexed
> def [](n)
> to_a[n]
> end
>end
>
>class String
> include Indexed
>end
>
>if __FILE__
> p "abcdefg".gsub(/./,"\\&\n")[1]
>end
I know, I know! Unfortunately, IMHO of course, matz has decided
that `"gotoken"[2]' would not deliver a character but an integer. I
have struggled many times over this trap!
[...]
>I don't agree it. Because we can define a class which has `each' but
>`collect'. A typical case is potentially infinitely many sequence.
>For example, an mathematical sequence
>
> class Trajectory
> def initialize(init, &map)
> @init = init
> @map = map
> end
>
> def each
> s = @init
> loop do
> yield(s)
> s = @map.call(s)
> end
> end
> end
>
> if __FILE__ == $0
> chaos = Trajectory.new(0.1){|x| 4.0*x*(1.0-x)}
> chaos.each{|x| break if x > 0.99999; p x}
> end
>
>In this case, the halting problem of `each' depends. You may claim
>that it is NOT an example of Enumeration but I feel this `each' IS
>very `each' because I think an enumeration is a *process* rather than
>an *evaluation*, so it should not be restricted to something to halt.
>A usage of unbounded `each' is a substitute for `while'.
Your class is very interesting :-) So please sorry for being
obstinate, but...
1. Your class is tricky coded. It seems to be a open-end enumeration.
So you cannot simply include Enumerable, as that module awaits
self-determinish enumerations. Here no method of Enumerable would
work well, you have to break that enumeration manually by break.
These are not the conditions Enumerable would like to use the
`each' method.
2. As Trajectory didn't include Enumerable, it would also not have to
delete or overwrite that `[]' method. But I have to agree, that my
previously post was a little bit confusing. It should not be
read as: "... that every class which provides an `each' method,
..." but instead as "... that every class which includes module
Enumerable, ...". Do you agree then?
3. But despite the fact, that Trajectory didn't include Enumerable,
it could use my proposed `Enumerable#[]' method too. Or implement
one of its own, like:
class Trajectory
def [](i)
index = 0
each do |element|
return element if i == index
index += 1
end
nil
end
end
>
>
>
>By the way, I think the current problem (i.e., our frustration about
>Range) came from the lack of easy way to make a subclass which is a
>result of appended/modified a kind of methods: for instance,
Oops! I think, I didn't understand your desires here.
>
> class FloatWithSucc < Float
> def succ
> self + 0.3
> end
> end
I again don't understand it.
>
>It doesn't work because the value of succ is not FloatWithSucc. This
>kind of difficulty weaken Range, maybe.
Sorry for my thumpness :-) But I really don't understand what you
want here!
>
>-- gotoken
\cle