lua-users home
lua-l archive

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


It was thus said that the Great Coroutines once stated:
> On Tue, Aug 12, 2014 at 3:38 PM, Geoff Leyland
> <geoff_leyland@fastmail.fm> wrote:
> 
> > If it helps understand, it’s legal to set 'table[“this has spaces”]',
> > but 'table.this has spaces’ obviously won’t work.  Table keys can be
> > pretty much anything (strings, numbers, tables, functions), but you when
> > you’re using the ‘.’ notation you can only use keys that parse as
> > identifiers.
> 
> What we need is Roberto to jump in explaining how to modify llex.c in
> Lua's source so you can use 'é' and other extended ASCII in the table
> shorthand form -- table.identifier is sugar of course :3

  In Lua 5.1, it uses isalpha() to check and therefore, it may or may not
allow other characters, depending upon the locale setting.  I was able to do
the following:

	export LANG=fr_FR
	xterm -fn -*-fixed-*-*-*-*-*-*-*-*-*-*-iso8859-1

and in the new xterm (done so because I usually run with a font based on
Unicode and not ISO-8859-1):

	lua
	Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
	> x = {}
	> x.système = 1
	> print(x.système)
	1
	>

  It failed when I tried LANG=fr_FR.UTF-8 (using a Unicode-based font),
probably because ISO-8859-1 is an 8-bit code only, whereas UTF-8 uses
multiple characters to represent non-ASCII based code-points (an educated
guess, since isalpha() is usually only given values between 0 and CHAR_MAX).

  Lua 5.2 uses a different method---it maintains its own character mapping
table in lctype.c, which would have to be modified appropriately depending
upon the locale and character set encoding you are using.

  The downside to this is that any Lua code written will not be generally
usable on other systems.

  -spc