lua-users home
lua-l archive

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


You wrote:

>Lua 4.1 (work3)  Copyright (C) 1994-2001 TeCGraf, PUC-Rio
>> print("hi\nbye")
>hi
>Bye
>> dostring("print(\"hi\nbye\")")
>error: unfinished string;
>  last token read: `"hi' at line 1 in string "print("hi..."
>stack traceback:
>   1:  function `dostring' [C]
>   2:  main of stdin at line 1
>>
>
>I would have expected both statements to produce the same result.

The second statement effectively is:
print("hi
bye")

you want 
dostring("print(\"hi\\nbye\")")

The \\ indicates that the slash is a literal slash so what lua during
dostring is:
print("hi\nbye")

HTH

Ben