Re: [sv-bc] Assigning type parameter via conditional operator

From: Gordon Vreugdenhil <gordonv@model.com>
Date: Thu Jul 29 2010 - 15:16:12 PDT

Rishiyur Nikhil wrote:
> > The conditional operator is defined on expressions, not on data types.
>
> And presumably for good reason--conditional expressions on types can
> complicate type-checking,
> e.g., by necessitating an interleaving of type-checking and parameter
> processing,
> instead of separate phases.

I don't think that is a reason. We already have that issue
in various contexts related to parametric types and "::" references into
those types as well as other situations (like default expressions with
parametric types, parameterized class derivation, etc).

I agree with Shalom -- the fundamental reason is just that ternary
expressions can't produce types, they can only produce values. I
wouldn't see anything inherently difficult with allowing a "type"
ternary operator where the conditional is required to be a constant
expression and an error results if the constant expression is
ambiguous. There shouldn't be anything new in the overall type
and parameter handling complexity given such a definition.

Gord.

>
> Nikhil
>
> On Thu, Jul 29, 2010 at 8:30 AM, Bresticker, Shalom
> <shalom.bresticker@intel.com <mailto:shalom.bresticker@intel.com>> wrote:
>
> Hi,
>
>
>
> The language does not allow it.
>
> The conditional operator is defined on expressions, not on data types.
>
>
>
> Regards,
>
> Shalom
>
>
>
> *From:* owner-sv-bc@eda.org <mailto:owner-sv-bc@eda.org>
> [mailto:owner-sv-bc@eda.org <mailto:owner-sv-bc@eda.org>] *On Behalf
> Of *Abhishek Jain
> *Sent:* Thursday, July 29, 2010 3:18 PM
> *To:* sv-bc@eda.org <mailto:sv-bc@eda.org>
> *Subject:* [sv-bc] Assigning type parameter via conditional operator
>
>
>
> Hi,
>
> Why I am not able to assign (or why language does not allow) a
> parameter type value based on conditional expression . For example
> in the below mentioned code assignment of TT_FAIL has syntax error.
> module A;
> parameter int WIDTH = 10;
> parameter int WIDTH_MAX = WIDTH == 10 ? 10:5;
> parameter type TT = int;
> * parameter type TT_FAIL = WIDTH == 10 ? int:logic;*
> endmodule
>
> Thanks,
> Abhishek
>
>
> --
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>,
> and is
> believed to be clean.
>
> ---------------------------------------------------------------------
> Intel Israel (74) Limited
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
>
> --
> 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* <http://www.mailscanner.info/>, and is
> believed to be clean.

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Jul 29 15:16:33 2010

This archive was generated by hypermail 2.1.8 : Thu Jul 29 2010 - 15:19:11 PDT