RE: [sv-bc] Musings on array assignment compatibility

From: <jonathan.bromley_at_.....>
Date: Tue Jun 02 2009 - 09:59:03 PDT
Dave Rich wrote:

> BTW your examples are all packed arrays, not unpacked.

Ouch - that's embarrassing.  Thanks for pointing it out. 
Of course I intended them to be unpacked.

Thanks for the other comments too.  One specific response:

> int A[2][2];
> byte B[2][2];
>
> Isn't the intent clearer to write as
>   foreach(A[i,j]) A[i][j] = B[i][j];
> rather than 
>   $cast(A,B);

Definitely; but the problem is - and has always been -
that this only works because you happen to know
that all the dimensions have matching bounds and
increments.  Given

  int A[1:2][1:0];
  byte B[1:0][10:11];

things get much, much messier.  Of course it *can*
be done, thanks to the query functions, but it's
not pretty.  And I don't think there is any really
general way for a user to code such a copy operation,
except perhaps by some very creative use of macros.
-- 
Jonathan Bromley


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jun 2 10:03:08 2009

This archive was generated by hypermail 2.1.8 : Tue Jun 02 2009 - 10:03:54 PDT