On Mon, 11 Jan 2010 20:10:45 -0800, John Stanley <> wrote:
>On Mon, 11 Jan 2010, wrote:
>
>> On Wed, 6 Jan 2010 12:52:51 -0800, John Stanley <> wrote:
>>
>>>
>>> The auto-conversion of numbers to strings and back in perl makes it
>>> difficult to manage significant figures without keeping that information
>>> separately. Even something simple like:
>>
>> $number started as a string and ended as a string.
>
>I did not say that the contents of $number changed without an assignment,
>I said that the value was converted from string to numeric as necessary.
>
>> I don't think its too tricky to understand that numeric
>> operations should be homogenous, and print is just a conversion,
>> accurate or not, of a temporary, a snapshot of the variable,
>> in space and time, that has absolutely nothing to do with assigning
>> to the variable.
>
>I didn't say it was tricky to understand, and I didn't say that print
>assigned anything to anything. 'Print' was there only to show the result
>of the operations being performed on the values.
>
>> There is nothing extrordinary about Perl in that regard, same numeric
>> base conversion problems as any other language.
>
>Perl is unique in the sense that it will AUTOMATICALLY convert from string
>to number when it is performing operations that require it. Other
>languages, at least those I am familiar with, require the programmer to
>know which is which and convert as required.
>
I'm sure there are other typeless languages out there.
>While there was no actual conversion of the stored values in the code I
>wrote, it was trivial demo code showing the loss of information by the
>operations themselves, and you would expect real code would have a few
>assignments saving the incorrect results.
Yes, I agree entirely. My point was that real code involving
numeric calculations won't mix string/number conversions except on entry
points or initialization, and coerce to a number if its a typeless language
if the language supports that. Even in Perl you can do that if precautions
are taken.
So significance is ludicrous in the OP's context of conversion, then assignment.
Precision is everything, the least precise number as it interracts with calculations,
is the limiting factor of significance. Significance is secondary.
I wouldn't use Perl as a numerical methods language, but it could be done.
For engineers/math types usually thier first project in Perl is to try to
convert some numeric project, and the freewheeling conversions are a trap for them.
I think the term "automatic conversion" is a misnomer since clearly one can
usually point to the offending line of code involving string assignment or
cataenation/assignment operators. Once the string side is breaced, the variable
is tainted with respect to numeric calculations. There should only be one way
conversions, number -> temporary -> string -> print. Entry points are a different
issue.
-sln