RE: [sv-bc] Question on void-returning functions


Subject: RE: [sv-bc] Question on void-returning functions
From: Brad Pierce (Brad.Pierce@synopsys.com)
Date: Thu Aug 28 2003 - 14:44:50 PDT


There is an open SV-BC issue about this BNF problem --

    http://www.eda.org/sv-bc/display_issue.cgi?issue_num=65

I will add a proposal.

-- Brad

-----Original Message-----
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org]On Behalf Of
Warmke, Doug
Sent: Thursday, August 28, 2003 2:38 PM
To: 'sv-bc@server.eda.org'
Subject: [sv-bc] Question on void-returning functions

Hi SV-BC,

We are wondering about the LRM treatment of discarding fn results via a
cast to void:

a. "Function calls are expressions unless of type void, which are
statments."
   LRM 10.3.1. This certainly seems reasonable.

b. Then we can effectively turn a non-void fn call into a void fn call
   via casting (LRM 10.3.2):
   "...using the void data type to discard a function's return value,
   which is done by casting the function to the void type:
        void'(some_function());

c. Note that the example above shows a the void cast-fn as essentially a
   stand-alone stmt, not part of an expression. This makes perfect sense,
   since we are effectively turing the fn into a void fn, which 10.3.1 says
   are statements.

d. However, in the grammar, we have a void-cast-fn not as a statement,
   but as a 'primary' under A.8.4:
        primary ::= number
                | ...
                | function_call
                | void'(function_call)
                |...

e. Is this just an oversight, or are we missing out on something here?
   In a syntactic sense, one would expect to see a void cast as a statement

--
   just like the LRM example. Otherwise, as a primary, it supposedly can
appear
   in range expressions, with binary operators, etc. (A.8.3), which makes no
   semantic sense for void.

f. The reason for caring is to see if one can handle void-fn-calls and cast-to-void-fn-calls in as similar way as possible.

Thanks and regards, Doug Warmke



This archive was generated by hypermail 2b28 : Thu Aug 28 2003 - 14:46:35 PDT