On Fri, May 3, 2013 at 3:51 PM, David Korn <[email protected]> wrote:
> Subject: Re: [ast-developers] (( x=$y )) warns about efficiency but $(( x=$y 
> ))  does not
> --------
>
>> Is there a reason why ksh -n triggers a warning (( x=$y )) about
>> efficiency but $(( x=$y )) does not?
>>
>>
>
> In the second case, the shell has to do a conversion from number
> to string anyway whereas in the first case no conversions are made
> when y is already numeric for ((x == y)).

The logic has one flaw: $((...)) converts the *result* to a string,
but in (( x=$y )) and $(( x=$y )) the value of *y* is converted to a
string, too. That's two times a string conversion is made. IMO a
warning for an expansion of *y* in both (( x=$y )) and $(( x=$y )) is
justified.

>
> Also, the shell compiles ((...)) into reverse polish when there
> are no expansions during the read phase so that if used in a loop
> this will only happen once. Whereas, this will happen each
> time in loop for $((...)).

Why isn't $((...)) compiled into reverse polish notation if the input
doesn't require expansion?

Irek
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to