Subject: [sv-bc] Question on void-returning functions
From: Warmke, Doug (doug_warmke@mentorg.com)
Date: Thu Aug 28 2003 - 14:38:03 PDT
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:39:45 PDT