Subhamoy, It looks like you've answered your own question. The LRM considers assignment a unary operator. So the statement out1 = (temp = in); is really two unary assignments. The first is an assignment from an int to complex. The second assignment is the result of the previous assignment, which is a complex type, to another complex type. So you can only overload the assignment from int to complex, since complex to complex is already defined. That overloading function would look like: function complex assgn(int i); assgn.Real = i; assgn.imaginary = 0; endfunction ________________________________ From: owner-sv-bc@server.eda.org [mailto:owner-sv-bc@server.eda.org] On Behalf Of Subhamoy Pal Sent: Thursday, April 12, 2007 10:34 AM To: Steven Sharp; sv-ec@server.eda-stds.org; sv-bc@server.eda-stds.org Subject: [sv-bc] RE: [sv-ec] overloading an assignment operator Hi Steven, SV LRM 8.16 has these lines. ================ Overloading the assignment operator also serves to overload implicit assignments or casting. Here these are using the same functions as the unary +. bind = function float fcopyi(int); // cast int to float bind = function float fcopyr(real); // cast real to float bind = function float fcopyr(shortreal); // cast shortreal to float So it means LRM gives provision for overloading assignment. Thank, Subhamoy -----Original Message----- From: Steven Sharp [mailto:sharp@cadence.com] Sent: Thursday, April 12, 2007 10:55 PM To: sv-ec@eda-stds.org; sv-bc@eda-stds.org; Subhamoy Pal Subject: Re: [sv-ec] overloading an assignment operator The LRM lists the operators that can be overloaded, and it does not include assignment. There is other text that indicates that this was not an oversight. The LRM only allows overloading of operators when applied to data types that would otherwise be illegal for them. Assignment is legal for all data types. The LRM also explicitly talks about arithmetic operators, which does not include assignment. So it seems quite clear that an assignment operator cannot be overloaded. Steven Sharp sharp@cadence.com -- This message has been scanned for viruses and dangerous content by MailScanner <http://www.mailscanner.info/> , and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Apr 12 10:54:32 2007
This archive was generated by hypermail 2.1.8 : Thu Apr 12 2007 - 10:54:56 PDT