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

From: Rich, Dave <Dave_Rich_at_.....>
Date: Tue Jun 02 2009 - 20:43:13 PDT
If the arrays do not have matching bounds and increments, and the
element types are not equivalent, I question the value of having a piece
of syntax that lets you blindly make an assignment from one array to
another.

I feel the UAC form covers the majority of cases, and the rest (like the
foreach'() cast) can be left for an enhancement in a future revision.

> -----Original Message-----
> From: Jonathan Bromley
> Sent: Tuesday, June 02, 2009 9:59 AM
> To: Rich, Dave
> Cc: sv-bc@server.eda.org; sv-ec@server.eda.org
> Subject: RE: [sv-bc] Musings on array assignment compatibility
> 
> 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 20:50:22 2009

This archive was generated by hypermail 2.1.8 : Tue Jun 02 2009 - 20:52:53 PDT