[#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:00407] New feature for Ruby?
From:
Clemens.Hintze@...
Date:
1999-07-01 02:40:00 UTC
List:
ruby-talk #407
Hi all,
I have begun to learn, how to extend Ruby using C. Doing that, I think
I can do some "real" work while learning.
As it has disturbes me several times, that a Range is only able to
iterate upwards but not downwards, I have chosen to add some features
to class Range and others, to let Range behave more like Smalltalk's
Intervall class.
So here are my ideas:
I would propose, that the class Range should behave more like the Interval
class of Smalltalk. That means it should be possible to do the
following:
- Range::new(1, 9)
- Range::new(1, 9, 2)
- Range::new(1, 9, -2) -- ERROR!
- Range::new(9, 1)
- Range::new(9, 1, 2)
- Range::new(9, 1, -2) -- ERROR!
- Range::new("a", "z", 3)
- Range::new(1.2, 2.9, 0.01)
As you can see, I would like to express the stepsize only via an
absolute value. The direction should only be given by "beg < end" or "beg
> end". I would raise an exception if the stepsize would be negativ, as
the general syntax should be:
Range::new(beg, end, step=1)
That means the beginning ever comes first. If here I had a negative
stepsize, I would, probably, never reach my end.
The call "Range::new(1, 9)" or "Range::new(9, 1)" could also be
written as "1..9" and "9..1" (perhaps we could have a global function
"range" (like Python) which would instantiate Ranges via Range::new?).
Every class which wants to be used as Range, should implement a
"succ", "pred" and a "compare method" to enable us to detect the end
of iteration.
The "succ" and the "pred" method should be able to get an optional
argument describing the increment/decrement size. Whereas 5.succ(-2)
would be the same as 5.pred(2)! And vice versa.
Furthermore it would be nice to have a read-access function "[]", so
that the following would be possible:
r = "a".."z" # or Range::new("a", "z")
print r[3] # would print 'c'!
The special case would be the String class, as here the "succ" and the
"pred" functions would do a magic addition like in Perl. That means:
"z".succ # would deliver "aa"
"aa".pred # would deliver "z"
Please let me know your opinion! Is that all silly, or would you also
like such features?
Bye,
Cle.
--
this message is re-posted by matz the list admin.