[#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,

[#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:

[#443] — Michael Hohn <hohn@...>

Hello,

26 messages 1999/07/09
[#444] interactive ruby, debugger — gotoken@... (GOTO Kentaro) 1999/07/09

Hi Michael,

[ruby-talk:00438] Re: New feature for Ruby?

From: gotoken@... (GOTO Kentaro)
Date: 1999-07-09 00:19:44 UTC
List: ruby-talk #438
Hi

In message "[ruby-talk:00431] Re: New feature for Ruby?"
    on 99/07/07, Clemens Hintze <c.hintze@gmx.net> writes:
>I will certainly send it to you before I give it to a magazin. But the
>problem is... Do you understand German? ;-)

Oh! Why do you know that Ich war fleissig Schuler nicht???  As you
guess, I can't understand German.  But please let me know when you
write. I'll try to read that. 

>>For such objects, I feel a suitable name is `Sequence' rather than
>>Interval. The name Sequence itself means descrete series, i.e.,
>>enumerable and one dimensional. But Interval reminds me and
>>mathematicians so general region as it may be use to a continuum or a
>>higher dimensional structure. Other opinions?
>
>It seems only mine :-) I think, that Sequence would also be okay,
>perhaps. As I have told you, the name is coming from the Smalltalk
>world not from any logical or even mathematical insight!

My apologies if you feel that I say same things again and again <bow>. 
I remember your naming is from Smalltalk.  Though it is not bad, I'd
like to name to be more plausible or more intelligible.  I believe the
name is very important; The most part of design, I believe, is
choosing the name.  A suitable name leads us what feature should be
supported.  I use mathematics to name in many case because just I do
not have the sense of word in English. I'm not intending ``the world,
be logical'' :-)

>class or even call that class Sequence! I only want all these features
>build-in into the interpreter, as it should be possible to iterate
>forth and back with every stepsize. *Damned*, every simple BASIC
>interpreter could do that! :-(

Me too. Your opinion is very persuasive. However, 
Regarding Integer only, int.step(to, step) can make it:

  % ruby -e '10.step(1, -2){|i| p i}'
  10
  8
  4
  6
  2
  %

Is it esoteric? 

Nor...

>It really hurts me, that the mighty Ruby have use some esoteric
>methods to archive the same goal :-(

Perhaps, I don't understand the above sentence, maybe. 


By the way, I introduce tips to redefine `new' here.  You can use it
in order to modify the Range to have some properties (e.g., stepsize)
by specifying them as options.


class Range
  class << self
    alias __new__ new
    private :__new__

    def new(first, last, succ = nil, pred = nil, order = nil)
      f = first
      l = last
      res = __new__(f, l)
      res.instance_eval{init(f, l, succ, pred, order)}
      res
    end
  end

  def init(first, last, succ_proc = nil, pred_proc = nil, order = nil)
    @succ_proc = succ_proc
    @pred_proc = pred_proc
    @order = order
  end

  private :init

  attr_reader :succ_proc, :pred_proc
end

if __FILE__ == $0
  p Range.new(1,3)
  p Range.new(1,2,3,-3).succ_proc
end

In This Thread