lua-users home
lua-l archive

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


On Fri, Feb 11, 2011 at 11:20:08AM +0200, Miles Bader wrote:
[about the following exchange]
>>> So, maybe in e.g. Lua 6, we may complete remove the implicit convert in Lua.
>> And break 95% of happily working Lua programs.
> >
> > I'd be very surprised if it actually caused much breakage at all
> > (... there's an easy way to find out, of course...)
> 
> ... and of course, even if it does, it's not really a problem -- the
> whole point of Lua's major-version upgrade policy is to allow desirable,
> but non-backward-compatible, changes.

Among the many things that I love about Lua is that there is no
"thought policing".  "Good" habits are not rammed down your throat.

At present I can read in a file containing student grades, with 
lines like
    1.5     3.8  9.1    10.0
and say:

for l in io.lines("filename") do
    total=0; for x in string.gmatch(l,"%s*(%S+)") do total=total+x end
    print(total)
    end

The '+' symbol is a clear, legible indication that 'total' and
'x' are expected to be coercible to numbers.  If any of my 
whitespace-delimited fields contains something that is invalid as 
a number, I'll get an "arithmetic on a string value" error.

I totally fail to see in what way my program will be improved if 
in Lua 6 I will be forced to write 'tonumber(x)' explicitly.   
If I really like to do that, I can do it now, it's fully legal.

Dirk