RE: [sv-bc] RE: [sv-ec] overloading an assignment operator

From: Subhamoy Pal <spal_at_.....>
Date: Fri Apr 13 2007 - 21:20:39 PDT
Hi Steven,
Thanks for correcting me. 

I don't think I have used any shortreal or real type in my example. It
was just to represent a complex number which looks like

typedef struct {
    int Real;
    int Imaginary;
} complex;


Hi Steven/Dave,
Now if we agreed on the point that "=" is an unary operator and we
should not use more than one argument in the function which binds to an
unary operator, can you please put a mantis item to add these things in
the LRM so that no more confusion gets created at later time.

Thanks,
Subhamoy

-----Original Message-----
From: Steven Sharp [mailto:sharp@cadence.com] 
Sent: Saturday, April 14, 2007 12:07 AM
To: sharp@cadence.com; Dave_Rich@mentor.com; sv-ec@eda-stds.org;
sv-bc@eda-stds.org; Subhamoy Pal
Subject: RE: [sv-bc] RE: [sv-ec] overloading an assignment operator


>From: "Subhamoy Pal" <spal@Magma-DA.COM>

>What you are saying is just one possibility right? You want += to be
>composed by independent overloading + and =.
>
>But if you check the list of operators can be overloaded, you will see
>+= itself is a valid operator for overloading.

Subhamoy,

I don't know what list you are checking.  I am looking at the list
in the grammar production for overload_operator, in Syntax 8-4 and
A.2.8.  It does not list += as an operator that can be overloaded.

Furthermore, section 8.16 says

"An assignment operator such as += is automatically built from both
the + and = operators successively, where the = has its normal meaning."

So += can end up being built from overloaded operations, but it cannot
be independently overloaded.

The only assignment-like operators that can be overloaded are ++ and --.
This makes sense, because you cannot assume what the representation of
the implicit value 1 would be for any user-defined type.

BTW, my concern about the validity of the assignment overloading between
int and float in the examples you quoted was wrong.  I have been writing
too much C code, and read float as the built-in floating point type.
But in Verilog, that is shortreal.  The float type in the examples is a
user-defined struct type.

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Apr 13 21:20:32 2007

This archive was generated by hypermail 2.1.8 : Fri Apr 13 2007 - 21:21:36 PDT