Re: empty expression lists in return statements?

From: John Lazzaro (lazzaro@CS.Berkeley.EDU)
Date: Thu Aug 24 2000 - 15:26:18 EDT


> Is it legal to write return statements with empty expression lists? Based on
> the definition in the standard it would be, however the description of
> return is silent on the issue.
>
> Given the asumption that return statements may appear inside control
> structures, it would make sense to allow return statements with empty
> expression lists.
>
> Any thoughts?

The key issue that should be clarified, I would think, would be the
width and value that should be returned by a return() line (or
alternatively, by "falling through" to the end of the opcode w/o
hitting a return statement). Two obvious approaches would be:

[1] A width-1 constant "0.0", so that the opcode can be used in
expressions.

[2] A width-0 expression, that should cause a syntax error if used
in an expression (similiar to functions returning void in C, I guess,
although I can't recall exactly what's supposed to happen in C if you
use a function returning void in an expression).

Sfront today implements [1] for the "fall through" case (and embarrassingly,
dumps core if you write return() -- oops!).

But on your main point, I agree that from a quick reread of the
standard with your general comments (i.e. <exprlists> of NULL are
allowed from the grammar, the text of return() doesn't seem to
directly comment on the issue).

                                                                --jl

-------------------------------------------------------------------------
John Lazzaro -- Research Specialist -- CS Division -- EECS -- UC Berkeley
lazzaro [at] cs [dot] berkeley [dot] edu www.cs.berkeley.edu/~lazzaro
-------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 12:03:58 EST