On Tue, Jan 30, 2007 at 06:02:59PM +0100, TSa wrote:
: Another integer issue is how the ++ and -- operators behave. Do they
: coerce to int before the operation or do they keep nums as nums?
: E.g.
:   my $x = 3.25;
:   $x++;  # 4.25 or 4?
:   $x = -2.25;
:   $x--;  # -3.25 or -4 or -3?

Since Str obviously stays Str when you ++ it, I think Num does too.
Let each type decide for itself, but I think most types will not want
to auto-transmogrify themselves to a different type.  One exception
is that ++ of an Undef produces Int, unless it was an undefined prototype
of some actual type.  So

    Str $s;

probably increments $s to "A" or some such.

If ++ and -- are really .succ and .pred in disguise (see C++), then
I'm suddenly wondering if the successor of an iterator is the iterator
with one less element on the front.  In which case,

    for $*IN++ {...}

would read through the iterator.  That doesn't quite work unless we also
make it that $($*IN) returns the head of the iterator.  So maybe that's
just a bogus idea.


Reply via email to