29.05.2014 Views

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

tex.print("access")<br />

else<br />

tex.print("no access")<br />

end<br />

tex.print(global.characters.data[0xA9].contextname)<br />

\stopusercode<br />

This gives: ‘user 1 user 2 no access copyright’.<br />

If you're writing a module, you might want to reserve a private namespace. This is done<br />

with:<br />

\definenamedlua[mymodule][my interesting module]<br />

Now we can say:<br />

\startmymodulecode<br />

help = { "help" }<br />

tex.print(help[1])<br />

\stopmymodulecode<br />

This gives: ‘help’. <strong>The</strong> information is remembered:<br />

\startmymodulecode<br />

tex.print(help[1])<br />

\stopmymodulecode<br />

Indeed we get: ‘help’.<br />

Just to check the isolation we try:<br />

\startusercode<br />

tex.print(help and help[1] or "no help")<br />

\stopusercode<br />

As expected this gives: ‘no help’ but when we do the following we will get an error message:<br />

\startusercode<br />

tex.print(help[1])<br />

\stopusercode<br />

! LuaTeX error :2: attempt to index global<br />

'help' (a nil value)<br />

stack traceback:<br />

:2: in main chunk.<br />

298 User code

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!