Thanks Matz... see below.

In article <E13ogHD-0006V0-00 / ev.netlab.zetabits.co.jp>,
  matz / zetabits.com (Yukihiro Matsumoto) wrote:
> Hi,
>
> In message "[ruby-talk:5862] succ but no pred? (& the MURKY award)"
>     on 00/10/26, "Hal E. Fulton" <hal9000 / hypermetrics.com> writes:
>
> |Is there some special reason that Ruby has (here and there)
> |a successor function (succ) but never a predecessor function
> |(pred)?
>
> Two reasons:
>
>   * Perl does not have magic decrement
>
>   * I was (and still is) too tired to define what should be the exact
>     behavior of magic decrement myself.

OK... but for numbers it is trivial. Given an Integer#succ, should we
not have an Integer#pred also?

In fact, if we defined succ! and pred! also, these could serve as
preincrement and predecrement operators (++x, --x) which some C
programmers might miss. That is another issue. (There would still be no
"post" versions, but these are more problematic anyway.)

And as for decrementing strings -- my intuition (which may be wrong!)
says that it is no harder than incrementing... we would need to ensure
that x.succ.pred == x and x.pred.succ == x for all but the boundary
cases.

And there must be boundary cases. Just as there must be at least one
string that does not have a successor, likewise there must be at least
one string without a predecessor. (I am not sure about null strings.)

This is not a big deal for me... I have never used String#succ or
heard anyone else claim to use it.

But I do like to see regularity -- if Lightbulb#screw exists, I want
Lightbulb#unscrew to be there also. In fact, I think there are times
when we should say, "Both or neither! But not just one."

--
Hal Fulton


Sent via Deja.com http://www.deja.com/
Before you buy.