Re: [sv-bc] Ambiguous declaration / initialization in for-loop

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Fri Oct 28 2005 - 10:59:08 PDT
Chris,

Think of the enhanced for-loop

    for ( int count = 0, done = 0, j = 0; j * count < 125; j++, count++)
        $display("Value j = %d\n", j );

as

    begin
      int automatic count, done, j;
      for ( count = 0, done = 0, j = 0; j * count < 125; j++, count++)
        $display("Value j = %d\n", j );
    end

The enhanced for-loop can be recoginized by the data_type after the
opening paren.  If there is no data_type there, it is an old-style
for-loop.  If there is a data_type, then it's an enhanced for-loop.  In
an enhanced for-loop all the control variables are locally declared. 

I recommend only using the enhanced for-loop.

-- Brad
Received on Fri Oct 28 10:59:12 2005

This archive was generated by hypermail 2.1.8 : Fri Oct 28 2005 - 10:59:27 PDT