lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


thanks for not saying RTFM :-)

> -----Original Message-----
> From:	Roberto Ierusalimschy [SMTP:roberto@inf.puc-rio.br]
> Sent:	Tuesday, July 20, 1999 2:12 PM
> To:	Multiple recipients of list
> Subject:	Re: goto 
> 
> > 	It's unfortunate that 'return' has to be the last statement in a
> > function, [...]
> 
> It doesn't have to. For syntactical reasons, 'return' must be the last 
> statement in a block, not in a function. The reason for this is that, as 
> Lua does not use semicolons to separate statements, a fragment like 
> 
>   return
>   print("ok")
> 
> would be interpreted as
> 
>   return print("ok")
> 
> 
> It is right to use a 'return' just before an 'end', 'else' or 'until'.
> Usually these are the places where you want to use a return. Otherwise,
> you can create a block just for this:
> 
>   do return end
> 
> -- Roberto