[metaas-dev] ElseIf

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


On Fri, Dec 14, 2007 at 07:35:41PM -0500, Matthew J Tretter wrote:
> >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.
>
> That makes perfect sense. However, given the following,
> 
> if(){
> } else {
>   foo="bar";
>   bar="foo";
> }
> 
> wouldn't the new getElse method need to return a StatementContainer  
> (as opposed to a Statement)?

Actually, we can have both, since the statement attached to this
else-clause is a block-statement; i.e. an ASBlock instance. ASBlock
implements both Statement and StatementContainer interfaces :)

The reason for ASBlock and StatementContainer interfaces both existing
(while essentially doing the same thing) is that we also have ASMethod
implement StatementContainer, so that we can add code to methods
directly, i.e. we can say,

  meth.addStmt(..)

rather than requiring stuff like,

  meth.getBody().addStmt(..)


ta,
dave

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



More information about the metaas-dev mailing list