[sv-ec] 5.7 example question

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Wed Nov 09 2005 - 23:25:09 PST
Hi,

What do you say about the last example in 5.7 ?

QUOTE:
Similarly, the source of an assignment can be a complex expression
involving array slices or concatenations. For
example:

string d[1:5] = '{ "a", "b", "c", "d", "e" }; 
string p[]; 
p = { d[1:3], "hello", d[4:5] };

The preceding example creates the dynamic array p with contents: "a",
"b", "c", "hello", "d", "e".
:ENDQUOTE

Is the assignment to p in a legal form?

If so, why?
If not, how should it be done?

I got the following response from Brad Pierce:

"I think the committees agreed to "punt" on this issue, because no one
provided a detailed semantics for how it was supposed to work, and no
entity considered the issue important enough to vote 'no' over it.

As far as I know, there is no other way to get the splicing behavior of
that example.  Without it, you would need to write

      p = '{ d[1], d[2], d[3], "hello", d[4], d[5] };

But that methodology breaks down if the indices are parameterized
instead of simple literals.  In that case, the only alternative is to
use two for loops."

Thanks,
Shalom
Received on Wed Nov 9 23:25:15 2005

This archive was generated by hypermail 2.1.8 : Wed Nov 09 2005 - 23:25:21 PST