[sv-ec] Associative array default value

From: Bresticker, Shalom <shalom.bresticker@intel.com>
Date: Sun Oct 24 2010 - 02:07:30 PDT

Hi,

7.9.11 says,

"Associative array literals use the '{index:value} syntax with an optional default index. Like all other arrays, an associative array can be written one entry at a time, or the whole array contents can be replaced using an array literal.

For example:

// an associative array of strings indexed by 2-state integers,
// default is "hello".

string words [int] = '{default: "hello"};

// an associative array of 4-state integers indexed by strings, default is -1

integer tab [string] = '{"Peter":20, "Paul":22, "Mary":23, default:-1 };

If a default value is specified, then reading a nonexistent element shall yield the specified default value, and no warning shall be issued. Otherwise, the default initial value as described in Table 7-1 shall be returned.
Defining a default value shall not affect the operation of the associative array methods (see 7.9)"

Question: the examples only show the use of a default in an associative array initialization. If such an assignment is performed to an associative array later in the simulation, does it become a new default value, or does it have that effect only if specified at initialization?

In the implementations I tested, this assignment did change the default. I think the LRM should be explicit about this.

Thanks,
Shalom

Shalom Bresticker
Intel LAD DA, Jerusalem, Israel
+972 2 589 6582 (office)
+972 54 721 1033 (cell)
http://www.linkedin.com/in/shalombresticker

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Sun Oct 24 02:07:58 2010

This archive was generated by hypermail 2.1.8 : Sun Oct 24 2010 - 02:08:29 PDT