Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On 4-9-2012 20:44, Marco Patzer wrote: On 2012-09-04 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Why does adding semicolon not work? Do you have a example? \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext \ctxlua{context(tostring(some condition)} given that the condition returns true/false - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Lua conditionals fail inside \starttexdefinition
Hi, I discovered strange behaviour concerning Lua conditionals within texdefinitions. ConTeXt complains: 'then' expected near 'thenelseend'. I guess it has something to do with how the content of a texdefinitions is grabbed. Seems like a bug or is this by design? % This works fine \def\mycmd{% \startluacode if true then else end \stopluacode} % This one fails % \starttexdefinition mycmd % \startluacode % if true then % else % end % \stopluacode % \stoptexdefinition \startluacode userdata = userdata or { } function userdata.myfun() if true then else end end \stopluacode % This also works fine \starttexdefinition mycmd \luacode{userdata.myfun()} \stoptexdefinition \mycmd Marco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
Am 04.09.2012 um 14:21 schrieb Marco Patzer home...@lavabit.com: Hi, I discovered strange behaviour concerning Lua conditionals within texdefinitions. ConTeXt complains: 'then' expected near 'thenelseend'. I guess it has something to do with how the content of a texdefinitions is grabbed. Seems like a bug or is this by design? When you use the texdefinition environment to create a command the end of line character which results normally in a space is ignored sees “thenelseend” as a single string, in such a case you can add a space and put a comment sign at the end of the line. % This one fails % \starttexdefinition mycmd % \startluacode % if true then % else % end % \stopluacode % \stoptexdefinition \starttexdefintion mycmd \startluacode if true then % else % end \stopluacode \stoptexdefinition Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On Tue, 4 Sep 2012, Wolfgang Schuster wrote: Am 04.09.2012 um 14:21 schrieb Marco Patzer home...@lavabit.com: Hi, I discovered strange behaviour concerning Lua conditionals within texdefinitions. ConTeXt complains: 'then' expected near 'thenelseend'. I guess it has something to do with how the content of a texdefinitions is grabbed. Seems like a bug or is this by design? When you use the texdefinition environment to create a command the end of line character which results normally in a space is ignored sees “thenelseend” as a single string, in such a case you can add a space and put a comment sign at the end of the line. % This one fails % \starttexdefinition mycmd % \startluacode % if true then % else % end % \stopluacode % \stoptexdefinition \starttexdefintion mycmd \startluacode if true then % else % end \stopluacode \stoptexdefinition Why does adding semicolon not work? Aditya___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
Am 04.09.2012 um 20:24 schrieb Aditya Mahajan adit...@umich.edu: Why does adding semicolon not work? Do you have a example? Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On 2012-09-04 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Why does adding semicolon not work? Do you have a example? \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext Marco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
Am 04.09.2012 20:44, schrieb Marco Patzer: On 2012-09-04 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Why does adding semicolon not work? Do you have a example? \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext that is no Lua syntax Herbert ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On 2012-09-04 Herbert Voss herbert.v...@fu-berlin.de wrote: Hi Herbert, \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext that is no Lua syntax if true then; print(true) else; print(false) end This snippet fed into a standalone Lua interpreter prints “true” on the terminal. I admit, I did not look up the syntax in the manual, but I have in mind that semicolons can be used to separate statements that are on one line. Marco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On Tue, 4 Sep 2012, Herbert Voss wrote: Am 04.09.2012 20:44, schrieb Marco Patzer: On 2012-09-04 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Why does adding semicolon not work? Do you have a example? \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext that is no Lua syntax I thought that semicolons were optional in lua are equal to end of lines. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On Tue, Sep 4, 2012 at 9:05 PM, Marco Patzer home...@lavabit.com wrote: On 2012-09-04 Herbert Voss herbert.v...@fu-berlin.de wrote: Hi Herbert, \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext that is no Lua syntax if true then; print(true) else; print(false) end This snippet fed into a standalone Lua interpreter prints “true” on the terminal. Not in my lua interpreter: saving the snippet into test.lua $lua test.lua gives lua: test.lua:1: unexpected symbol near ';' -- luigi ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
Am 04.09.2012 21:05, schrieb Marco Patzer: if true then; print(true) else; print(false) end This snippet fed into a standalone Lua interpreter prints “true” on the terminal. I admit, I did not look up the syntax in the manual, but I have in mind that semicolons can be used to separate statements that are on one line. voss@shania:~/ConTeXt lua zzz.lua lua: zzz.lua:1: unexpected symbol near ';' voss@shania:~/ConTeXt lua -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio Herbert ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On Tue, Sep 4, 2012 at 9:05 PM, Aditya Mahajan adit...@umich.edu wrote: On Tue, 4 Sep 2012, Herbert Voss wrote: Am 04.09.2012 20:44, schrieb Marco Patzer: On 2012-09-04 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Why does adding semicolon not work? Do you have a example? \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext that is no Lua syntax I thought that semicolons were optional in lua are equal to end of lines. Aditya __**__** ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/** listinfo/ntg-context http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/**projects/contextrev/http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net __**__** ___ http://www.lua.org/manual/5.1/manual.html#2.4.4 The unit of execution of Lua is called a chunk. A chunk is simply a sequence of statements, which are executed sequentially. Each statement can be optionally followed by a semicolon: : : 2.4.4 - Control Structures The control structures if, while, and repeat have the usual meaning and familiar syntax: stat ::= while exp do block end stat ::= repeat block until exp stat ::= if exp then block {elseif exp then block} [else block] end (as conseguence if exp then; block else; block end is not valid ) -- luigi ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
Am 04.09.2012 21:22, schrieb luigi scarso: http://www.lua.org/manual/5.1/manual.html#2.4.4 The unit of execution of Lua is called a chunk. A chunk is simply a sequence of statements, which are executed sequentially. Each statement can be optionally followed by a semicolon: : : 2.4.4 - Control Structures The control structures if, while, and repeat have the usual meaning and familiar syntax: stat ::= while exp do block end stat ::= repeat block until exp stat ::= if exp then block {elseif exp then block} [else block] end (as conseguence if exp then; block else; block end is not valid ) yes, see also: http://www.lua.org/manual/5.1/manual.html#8 Herbert ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On 2012-09-04 Herbert Voss herbert.v...@fu-berlin.de wrote: voss@shania:~/ConTeXt lua zzz.lua lua: zzz.lua:1: unexpected symbol near ';' marco@homerow:/tmp$ lua t.lua true voss@shania:~/ConTeXt lua -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio marco@homerow:/tmp$ lua -v Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio Marco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
Am 04.09.2012 21:35, schrieb Marco Patzer: On 2012-09-04 Herbert Voss herbert.v...@fu-berlin.de wrote: voss@shania:~/ConTeXt lua zzz.lua lua: zzz.lua:1: unexpected symbol near ';' marco@homerow:/tmp$ lua t.lua true voss@shania:~/ConTeXt lua -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio marco@homerow:/tmp$ lua -v Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio the syntax changes, see http://www.lua.org/manual/5.2/manual.html#9 Herbert ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On Tue, Sep 4, 2012 at 9:35 PM, Marco Patzer home...@lavabit.com wrote: On 2012-09-04 Herbert Voss herbert.v...@fu-berlin.de wrote: voss@shania:~/ConTeXt lua zzz.lua lua: zzz.lua:1: unexpected symbol near ';' marco@homerow:/tmp$ lua t.lua true voss@shania:~/ConTeXt lua -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio marco@homerow:/tmp$ lua -v Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio Because in Lua 5.2 there is the empty statements http://www.lua.org/manual/5.2/manual.html#3 3.3.1 – Blocks A block is a list of statements, which are executed sequentially: block ::= {stat} Lua has empty statements that allow you to separate statements with semicolons, start a block with a semicolon or write two semicolons in sequence: stat ::= ‘;’ So stat ::= if exp then block {elseif exp then block} [else block] end means that if exp then ; else ; end is valid. Luatex still uses lua 5.1.4 -- luigi ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua conditionals fail inside \starttexdefinition
On 2012-09-04 Herbert Voss herbert.v...@fu-berlin.de wrote: voss@shania:~/ConTeXt lua -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio marco@homerow:/tmp$ lua -v Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio the syntax changes, see http://www.lua.org/manual/5.2/manual.html#9 You're totally right. LuaTeX uses does not use lua 5.2 and therefore the semicolon syntax is wrong. I also get an “unexpected symbol” with lua5.1 Thanks for the clarification Marco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___