[metaas-dev] ElseIf

David Holroyd dave at badgers-in-foil.co.uk
Sat Dec 15 00:13:34 UTC 2007


On Fri, Dec 14, 2007 at 06:59:46PM -0500, Matthew J Tretter wrote:
> If your new method returned a Statement, what would be returned in the  
> case of a simple if...else? Would you need to create an ElseStatement  
> interface as well?

It's not that complicated, thankfully.  The 'else' is not a separate
statement, from a syntactic point of view, it's an optional part of the
if-statement itself.

Think,

  if ()
    {}
  else
    {}

vs.

  if ()
    {}
  else
    if ()
      {}

in the first case the else-clause contains a block-statement.  In the
second case, the else-clause contains another if-statement.  The
else-clause could contain any other kind of statement too, e.g. and
expression-statement,

  if ()
    {}
  else
    foo = "bar";

etc.


I think what I'll do is add a getElseStatement() method, which will
return Statement, or null when no else-clause is attached to the
if-statement.

I'll deprecate getElse() in favour of an elseBlock() method that does the
same thing (or something like that).


seems fair?
dave

-- 
http://david.holroyd.me.uk/



More information about the metaas-dev mailing list