[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Arithmetic on strings
- From: Andrew Starks <andrew.starks@...>
- Date: Sat, 7 Jul 2012 09:22:33 -0500
On Jul 7, 2012, at 6:44, Dirk Laurie <email@example.com> wrote:
> 2012/7/7 steve donovan <firstname.lastname@example.org>:
>> On Sat, Jul 7, 2012 at 11:33 AM, Miles Bader <email@example.com> wrote:
>>> Me too.
>> Ditto. The code it breaks is code that's going to break 'by accident'
>> in some way later.
> There's just one thing: input of numbers. At present, I can write:
> s=0; k=0
> grade="Ann 57, Bob 64,Cat 77, Don 62, Eve 51"
> for n in grade:gmatch("%d+") do s=s+n; k=k+1 end
> I don't see this code breaking "by accident".
> Are we really going to improve quality-of-life for the public
> by fascistically taking away this freedom?
> I vote for this solution: remove string coercion, but make it
> easy to enable/disable the necessary metamethods that give
> the same effect. For at least one release, let string coercion
> by metamethods still be the default.
I think that all coercion should be out of the language, including the
coercion of nil to false.
I also agree that all coercion should be allowed on all value types
throughmeta methods: tostring, tonumber, toboolean, totable. I think
that was the way, at some point, so there must have been a reason to
Having only, for example, tostring, seems arbitrary to the ignorant (me).