[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc1) now available
- From: Lavergne Thomas <thomas.lavergne@...>
- Date: Tue, 14 Jun 2011 14:17:13 +0200
Le 13 juin 2011 à 22:03, Roberto Ierusalimschy a écrit :
>> Why goto and not continue?
>
> Because goto is much more flexible. For instance, the source code for
> Lua has ~14 gotos and only 2 continues.
The continue discussion come one this list frequently and I've always
stayed away from them as for the easiest solution was to patch my copy
of Lua.
It's now 9 years I use Lua for a lot of every day data processing and
I've accumulated a lot of scripts for Lua 4.0, 5.0 and 5.1, all patched
to support continue.
I've done some quick stats on my scripts dirs to see own often I use
it and in which conditions and the result represent well my need of
it.
I've 883 scripts in these dirs for a total of 46208 lines of code (just
removing blank lines and comment lines) and 902 use of continue for 34
use of the until loop. (who prevent adding continue in Lua)
This mean more than one continue per script not taking account that
some of these scripts are in fact small libs used by a lot of others
scripts.
These numbers should be take with salt as the fact that continue is
available to me, make me use it ;-) and some of theses uses can be
rewritten without too much harm. And the second thing to take account
of is the kind of jobs most of these scripts do : processing textual
data where for loop on lines with a filter at start for ignoring
empty or comment lines.
Just for the sake of feeding the troll, I've counted the number of
goto I use in my C sources dirs and for a total 82340 lines of C, I've
found only 42 uses of goto and all of them are for handling errors
in complex case where I admit that some kind of clean exceptions in
C could be good.
But the only thing I want to remember from this last number is that
I write one third of my code in Lua. (and that I should try to increase
this ratio...)
Tom