[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: Drake Wilson <drake@...>
- Date: Fri, 11 Feb 2011 03:31:16 -0700
Quoth Dirk Laurie <dpl@sun.ac.za>, on 2011-02-11 12:14:56 +0200:
> At present I can read in a file containing student grades, with
> lines like
> 1.5 3.8 9.1 10.0
Something nobody's mentioned yet is that Lua numeric/string coercion
in Lua is naturally dependent on the C standard library---which means
it can be affected by the C locale! Lua doesn't call setlocale() by
default, but if any other part of your program does...
$ LC_ALL=fr_FR.UTF-8 lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> a = '1.3'; b = 1.3
> =a+b
2.6
> os.setlocale('')
> =a+b
stdin:1: attempt to perform arithmetic on global 'a' (a string value)
stack traceback:
stdin:1: in main chunk
[C]: ?
> =b
1,3
---> Drake Wilson
- References:
- 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
- Re: Is string always same as number? (the consistency of lua), Dirk Laurie