lua-users home
lua-l archive

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


Jay Carlson wrote:
> 
> a = [[b
> ]]
> 
> has two characters in it, regardless of whether it's typed at the command
> line or read from a file.

Normally, but not always.  It depends on the end of line sequence used in
the file and the one expected by the lexer.  I.e. a DOS file ('b' CR LF)
read on a Unix system you get these 3 chars, read on DOS you get 2 chars
('b' LF).  There are some other issues with line numbers, too.  You only
get reliable results when the parsed file was generated on a system with
the same EOL sequence.  Only then will the "text mode" ANSI stdio functions
convert them correctly to LF.  Maybe one should change this and should accept
all variants (CR - Mac, LF - Unix, or CR+LF - DOS) as a valid end of line
and always convert it to LF.  And if one interprets a CTRL-Z as an altern-
ative end of file one could even parse files on DOS in binary mode ;-)

> Is it a good idea to support "\\\n" such that
> 
> a = [[b\
> ]]
> 
> has only one character in it?

Better not.  Long strings are meant for literal text and shouldn't interpret
escape sequences.  Use

a=[[b]]

or

a=[[
b]]

Ciao, ET.


PS: Btw, different locales may give additional incompatibilities...