ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Trying to understand this ctxlua error
@ 2020-04-05 22:41 Gerben Wierda
  2020-04-06  0:54 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Gerben Wierda @ 2020-04-05 22:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1896 bytes --]

I got this error after I had changed some lua code:

tex error       > tex error on line 272 in file archimate-lua.new: ! Undefined control sequence

        warnIfVerbose( "Breaking off the processing of node %s\nNo 
      l...eak                                                                    xsi:type", node)
\luat_start_lua_code_indeed ...ormalexpanded {\endgroup \noexpand \directlua {#1
                                                                                }}
l.272 \stopluacode
                

<empty file>


The control sequence at the end of the top line of your error message was never
\def'ed. You can just continue as I'll forget about whatever was undefined.

I have been looking at that code for over two hours, not seeing anything wrong with it. But I’ve now finally found the culprit and I still do not get it.

The culprit was:

          warnIfVerbose( "Breaking off the processing of %s\n No elementRef", node)

The problem goes away when I use:

          warnIfVerbose( "Breaking off the processing of %s\nNo elementRef", node)

(I don’t want the line after the node is printed to begin with a space).

But the lack of space between \n and N kills lua (apparently). For completeness (as string.format and texio.write_nl are also in play):

function warnWithLabelIfVerbose( str, ... )
  if verboseProgram then
    texio.write_nl( str .. string.format(...))
  end
end

function warnIfVerbose( ... )
  warnWithLabelIfVerbose("-----> ", ...)
end

Is this a lua bug? A ConTeXt bug? Expected behaviour? And if so, why is reported that on line 272 (where \stopluacode is) is the error? Or is the error message indeed helpful and do I just lack the know how to interpret it?

G

(Took me three hours, this one. Just removing that space that happened with some other changes was the culprit. Totally unexpected for me.)

[-- Attachment #1.2: Type: text/html, Size: 7333 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Trying to understand this ctxlua error
  2020-04-05 22:41 Trying to understand this ctxlua error Gerben Wierda
@ 2020-04-06  0:54 ` Wolfgang Schuster
  2020-04-06  9:48   ` Gerben Wierda
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2020-04-06  0:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Gerben Wierda

Gerben Wierda schrieb am 06.04.2020 um 00:41:
> I got this error after I had changed some lua code:
> 
> tex error       > tex error on line 272 in file archimate-lua.new: ! 
> Undefined control sequence
> 
>          warnIfVerbose( "Breaking off the processing of node %s\nNo
>        l...eak                                                          
>            xsi:type", node)
> \luat_start_lua_code_indeed ...ormalexpanded {\endgroup \noexpand 
> \directlua {#1
>                                                                          
>          }}
> l.272 \stopluacode
> 
> 
> 
> <empty file>
> 
> 
> The control sequence at the end of the top line of your error message 
> was never
> \def'ed. You can just continue as I'll forget about whatever was undefined.
> 
> I have been looking at that code for over two hours, not seeing anything 
> wrong with it. But I’ve now finally found the culprit and I still do not 
> get it.
> 
> The culprit was:
> 
>            warnIfVerbose( "Breaking off the processing of %s\n No 
> elementRef", node)
> 
> The problem goes away when I use:
> 
>            warnIfVerbose( "Breaking off the processing of %s\nNo 
> elementRef", node)
> 
> (I don’t want the line after the node is printed to begin with a space).
> 
> But the lack of space between \n and N kills lua (apparently). For 
> completeness (as string.format and texio.write_nl are also in play):
> 
> function warnWithLabelIfVerbose( str, ... )
>    if verboseProgram then
>      texio.write_nl( str .. string.format(...))
>    end
> end
> 
> function warnIfVerbose( ... )
>    warnWithLabelIfVerbose("-----> ", ...)
> end
> 
> Is this a lua bug? A ConTeXt bug? Expected behaviour? And if so, why is 
> reported that on line 272 (where \stopluacode is) is the error? Or is 
> the error message indeed helpful and do I just lack the know how to 
> interpret it?

ConTeXt expands TeX commands in a luacode-environment
and when you have \n followed by text you create a new
command with starts with \n but since it isn't defined
you get a error message.

In the example below the commented block produces
the same error message as you get.

\starttext

%\startluacode
%print("text\ntext")
%\stopluacode

\startluacode
print("text\n text")
\stopluacode

\stoptext

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Trying to understand this ctxlua error
  2020-04-06  0:54 ` Wolfgang Schuster
@ 2020-04-06  9:48   ` Gerben Wierda
  0 siblings, 0 replies; 3+ messages in thread
From: Gerben Wierda @ 2020-04-06  9:48 UTC (permalink / raw)
  To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2961 bytes --]

On 6 Apr 2020, at 02:54, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
> 
> Gerben Wierda schrieb am 06.04.2020 um 00:41:
>> I got this error after I had changed some lua code:
>> tex error       > tex error on line 272 in file archimate-lua.new: ! Undefined control sequence
>>         warnIfVerbose( "Breaking off the processing of node %s\nNo
>>       l...eak                                                                     xsi:type", node)
>> \luat_start_lua_code_indeed ...ormalexpanded {\endgroup \noexpand \directlua {#1
>>                                                                                  }}
>> l.272 \stopluacode
>> <empty file>
>> The control sequence at the end of the top line of your error message was never
>> \def'ed. You can just continue as I'll forget about whatever was undefined.
>> I have been looking at that code for over two hours, not seeing anything wrong with it. But I’ve now finally found the culprit and I still do not get it.
>> The culprit was:
>>           warnIfVerbose( "Breaking off the processing of %s\n No elementRef", node)
>> The problem goes away when I use:
>>           warnIfVerbose( "Breaking off the processing of %s\nNo elementRef", node)
>> (I don’t want the line after the node is printed to begin with a space).
>> But the lack of space between \n and N kills lua (apparently). For completeness (as string.format and texio.write_nl are also in play):
>> function warnWithLabelIfVerbose( str, ... )
>>   if verboseProgram then
>>     texio.write_nl( str .. string.format(...))
>>   end
>> end
>> function warnIfVerbose( ... )
>>   warnWithLabelIfVerbose("-----> ", ...)
>> end
>> Is this a lua bug? A ConTeXt bug? Expected behaviour? And if so, why is reported that on line 272 (where \stopluacode is) is the error? Or is the error message indeed helpful and do I just lack the know how to interpret it?
> 
> ConTeXt expands TeX commands in a luacode-environment
> and when you have \n followed by text you create a new
> command with starts with \n but since it isn't defined
> you get a error message.
> 
> In the example below the commented block produces
> the same error message as you get.
> 
> \starttext
> 
> %\startluacode
> %print("text\ntext")
> %\stopluacode
> 
> \startluacode
> print("text\n text")
> \stopluacode
> 
> \stoptext

OK, thanks. This means the ConTeXt environment mixes standard TeX (where \nfoo would be considered a TeX command) and lua string substitution (where \nfoo would mean a newline followed by foo), correct? I understand why that happens (otherwise one would have to escape all \ characters directed at TeX) but it really took me hours (because I did not understand the error message that correctly told me \Nno was the problem). It’s what you see depends on what you are looking for, I guess.

Maybe a warning in the documentation (or maybe there is one and I missed it)

G


[-- Attachment #1.2: Type: text/html, Size: 17671 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-06  9:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-05 22:41 Trying to understand this ctxlua error Gerben Wierda
2020-04-06  0:54 ` Wolfgang Schuster
2020-04-06  9:48   ` Gerben Wierda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).