[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is string always same as number? (the consistency of lua)
- From: Dirk Laurie <dpl@...>
- Date: Fri, 11 Feb 2011 12:14:56 +0200
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
- References:
- Re: Is string always same as number? (the consistency of lua), Axel Kittenberger
- Re: Is string always same as number? (the consistency of lua), steve donovan
- Re: Is string always same as number? (the consistency of lua), Axel Kittenberger
- Re: Is string always same as number? (the consistency of lua), steve donovan
- Re: Is string always same as number? (the consistency of lua), Axel Kittenberger
- Re: Is string always same as number? (the consistency of lua), Philippe Lhoste
- Re: Is string always same as number? (the consistency of lua), Xavier Wang
- Re: Is string always same as number? (the consistency of lua), Dirk Laurie
- Re: Is string always same as number? (the consistency of lua), Miles Bader
- Re: Is string always same as number? (the consistency of lua), Miles Bader