On Mon, 2004-05-17 at 13:51, Pedro Larroy wrote:

> I thought perl internally would know. At least in perl5 it has to know
> somehow, since you can $var++ when is numeric and also when it's a
> string, and behaves different in each case.

True.  Perl 5 scalars do keep track of the context in which you've used
the data they hold.  If you treat a scalar like a number, it'll behave
like a number.  There are some wacky corner cases, though, where you see
side-effecty action at a distance.  (I remember running across this at
least twice, though I don't remember specific examples.  DWIM usually
works well.)

As Luke suggests, there's also programmer clarity to consider.  If
determining how to compare depends on how you've used the variables to
compare, is it harder to understand the code?  The solution for an API
designer may be "be very careful, then!" but I'm not sure a language
designer has that luxury.

-- c

Reply via email to