octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constant folding


From: Vytautas Jancauskas
Subject: Re: constant folding
Date: Fri, 13 Dec 2013 17:33:03 +0200

On Fri, Dec 13, 2013 at 5:27 PM, John W. Eaton <address@hidden> wrote:
> On 12/13/2013 07:55 AM, Rik wrote:
>
>> The coding pattern
>>
>> while (1)
>>   ...
>>    if (condition)
>>      break
>>    endif
>> endwhile
>>
>> is pretty common and uses constants in the conditional.
>
>
> There should be no effect for that because "1" is already a constant value
> that can't be further reduced.  In order to have any effect, the constant
> expression must involve an operator of some kind.  I just looked at the
> parser again and constant folding only applies to binary and unary
> operators.  My recollection was that there were more cases (matrix
> constants, for example), but if there ever were, it looks like those have
> already been removed.  So I really think that this will have minimal impact.
>
> jwe

As a user I generally expect that my compiler or interpreter will do
constant folding. There are cases were an expression is easier to read
than a constant, especially if there are several of them with some
structure. Just saying.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]