On Thu, Jan 27, 2011 at 12:17 PM, Ed Avis <eda@waniasset.com> wrote: > I see. Personally, I'd take 'correct, but slightly slower' over 'a bit faster > in some cases, with surprising edge cases' any day. But isn't it possible to > have it both ways? The numeric value could be cached in the scalar and used > next time, but without flipping the switch to mark the scalar as numeric. Then > later numeric context uses would be fast, but the value would not mysteriously > change. > > I have only a loose idea of Perl internals so please forgive my ignorance here; > from a user's point of view not changing a variable just because it was *read* > in an arithmetic expression is definitely the right thing to do, but I am > uncertain of the practicalities of doing so in the perl interpreter. I think the real bug here is not that a scalar value can have both a numeric and a string value, but that some operators and keywords are polymorphic on the representation of the value. LeonThread Previous | Thread Next