[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 22:26:38 +0200
> do
> local smt = debug.getmetatable("")
> function smt.__add(a, b) return tonumber(a) + tonumber(b) end
> local an = tonumber(a) or error(a.." used in arithmetic is not a number", 2)
> local bn = tonumber(b) or error(b.." used in arithmetic is not a number", 2)
> return an + bn
> end
> debug.setmetatable("", smt)
> end
...
> ""Any fool can write code that a computer can understand.
> Good programmers write code that humans can understand."
>
True. Very, very true.
D.
- References:
- 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
- Re: Is string always same as number? (the consistency of lua), Dirk Laurie
- 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), Greg Falcon
- Re: Is string always same as number? (the consistency of lua), Dirk Laurie
- Re: Is string always same as number? (the consistency of lua), Axel Kittenberger