Hi Rudolf,

> On 15 Oct 2019, at 00:50, Rudolf Bahr <qu...@quasi.de> wrote:
> Now to your suggestion not to use "assert ()". Indeed it's a solution! My 
> program
> works! I append again its output (again just for fun!). Did you really try it 
> or
> has it been just an idea?

First, let me say that embedded lua versions are typically a little bit 
from standalone. Just how much different depends on the embedding program. 
is actually pretty close to standalone lua. Luatex adds a bunch of extension 
but it changes very little of the core language. And all those changes are 
in the luatex manual. None of those changes affect your minimal example, except
that lua errors are handled a little differently.

Note that standalone lua *also* produces an error, as that is what assert() is 
supposed to do. And when lua runs into an error, it ignores the rest of the 

  “... whenever an error occurs, Lua ends the current chunk and returns 
  to the application.” (from lua.org)

Standalone lua typically sees only one chunk (the file you pass on the command
line) but embedded lua implementation often see (sometimes many) more chunks.
In luatex’s case, each \directlua is a separate chunk (in ConTeXt, that means 
\startluacode block and every \ctxlua call is a separate chunk).

The only unusual thing here is that standalone lua silently quits and returns a 
non-zero exit code to the shell, whereas luatex gives you the typical TeX-style 
error prompt. The rationale for that is: lua errors can happen in many places 
your input file, and if they were silently ignored, your typeset pages could be 
wrong without you realising it.

And to answer your question above: I did not have to try or guess. I know about 
how assert() works because it is documented in the lua manual (and as it closely
mimics the assert() C function, that is easy for me to remember).

Best wishes,

If your question is of interest to others as well, please add an entry to the 

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net

Reply via email to