ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Diagnositics in LuaTeX
@ 2020-12-28 14:54 Henri Menke
  2020-12-28 16:09 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Henri Menke @ 2020-12-28 14:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users, LuaTeX discussion.

Dear lists,

Recently I've been working a bit on PGF/TikZ and many times I wished I had
certain metrics that are available in regular programming languages.  In
particular I am missing:

- A callback that is triggered when a macro is defined.  This would allow me to
trap when a cs is defined in the wrong place.  That could probably be done by
overriding `\def` but there are some gotchas with prefixes, e.g. `\long\def`.

- A callback that is triggered when a token is expanded (or executed in the case
of primitives).  In conjunction with the previous request, this would allow me
to measure code coverage by comparing which macros are defined and which ones
are used.

- Switches to trap on certain pathological events.  For example I want to trap
when TeX inserts a frozen \relax because a number couldn't be read.  Another
thing I want to trap is `Missing character: There is no <char> in font <font>!`.
There are probably more silent TeX errors that I currently don't have in mind.

Are these things possible in LuaTeX right now or could they be made possible in
the future?

Kind regards,
Henri

___________________________________________________________________________________
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] 2+ messages in thread

* Re: Diagnositics in LuaTeX
  2020-12-28 14:54 Diagnositics in LuaTeX Henri Menke
@ 2020-12-28 16:09 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2020-12-28 16:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Henri Menke, LuaTeX discussion.

On 12/28/2020 3:54 PM, Henri Menke wrote:
> Dear lists,
> 
> Recently I've been working a bit on PGF/TikZ and many times I wished I had
> certain metrics that are available in regular programming languages.  In
> particular I am missing:
> 
> - A callback that is triggered when a macro is defined.  This would allow me to
> trap when a cs is defined in the wrong place.  That could probably be done by
> overriding `\def` but there are some gotchas with prefixes, e.g. `\long\def`.

if you intercept for that reason you need to make the callback function 
situation aware which means that you can as well test things the tex 
which is way more efficient

> - A callback that is triggered when a token is expanded (or executed in the case
> of primitives).  In conjunction with the previous request, this would allow me
> to measure code coverage by comparing which macros are defined and which ones
> are used.

given the amount of expansion going on in the engine that would mean, 
for a reasonable large document, or for some complex macro package like 
pgf, many millions of

Also, what exactly is 'expanded'. Some tokens are handled directly, some 
enter an expansion call, others are macros that themselves use expansion 
to even get started. Basically you want to check each token that is read 
or accessed from internal storage (lists). Adding granilarity means many 
callbacks (each one checking if it's defined, then setting up lua, call 
the function, and go back to tex). There's also a lot of pushback ging on.

If you just hook into 'picking up a token', here are some numbers if we 
hook into that:

making context lmtx format: 4M (million)
simple tufte document with minimal font setup: 500K
loading tikz (with patterns lib): 3M
drawing simple pattern in tikz: 100K (1 cm circle with pdf pattern)
290 page luametatex manual: 105M

(ok, latex is probably much more efficient than context but it gives an 
idea)

> - Switches to trap on certain pathological events.  For example I want to trap
> when TeX inserts a frozen \relax because a number couldn't be read.  Another
> thing I want to trap is `Missing character: There is no <char> in font <font>!`.
> There are probably more silent TeX errors that I currently don't have in mind.

there is s missing glyph callback and with some juggling the 'no number' 
can be intercepted at the tex end ... you can set an error callback and 
look at the message

> Are these things possible in LuaTeX right now or could they be made possible in
> the future?
all is possile but this will not happen ... enabling callbacks like that 
would make luatex unuseable slow (which is probably not what you want 
because pgf is already kind of slow) (even checking for the callback 
being set takes time)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2020-12-28 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 14:54 Diagnositics in LuaTeX Henri Menke
2020-12-28 16:09 ` Hans Hagen

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).