[luatex] multiple callbacks

Hans Hagen pragma at wxs.nl
Sun Jan 4 22:41:12 CET 2009


Elie Roux wrote:
> Hans Hagen a écrit :
>> since there are multiple (conceptually different) solutions there will 
>> be no 'integrated solution' (we would end up with 
>> callback-variant-1.tex, callbacks-variant-2.tex etc).
> 
> I don't really understand why... if you say now "we have an integrated 
> solution, here it is, now use callback.add instead of callback.register 
> with this file", what's the problem?

this is just an example of a way to deal with callback management; 
luatex itself provides just mechanisms (in this case: 
callback.register); usage of them is not up to luatex but to the users 
(and normally organized in a macro package); the code i posted is usable 
but just a quick hack. if it can be used great

compare this with other primitive mechanisms, for instance

\font: there are several ways to implement font management systems (i'm 
isolating some code for open type that can be used by others but that 
can never be *the* definite answer)

\countdef : these are just primitives and macro packages implement the 
management of these registers (ther ei smuch overlap, but for instance 
the way inserst are handled might differ)

\attribute: there are many ways to use attributes and you might either 
or not use them for specific tricks (a macro package has to provide a 
way to define and use them in order to avoid conflicts)

\output and \shipout: each macro package has its own way to handle the 
output of a page and wrap it with headers and footers

\halign: just look in the tex tree and see ho wmany ways there are to 
construct tables, there is no one solution

> Again there is something I don't understand... isn't it only a Lua 
> problem? There are certainly issues I don't see here...

just consider lua in luatex to be a way to extend tex; luatex provides a 
few new concept (like attributes and callbacks) as well as access to 
internals, and using them is up to users and macro package writers

some macro packages go as far as redefine primitives and the same might 
happen for callback handling etc

so, in your case you can do something like:

tex/generic/roux/er-callback-handler.tex
tex/generic/roux/er-callback-application.tex

and then ask your users to load both; however, it might be that the 
macro package that you use already provides a callback handler (or it 
might use your i.e. the example handler)

now, say that you want to make a generic style something that is used in 
all kind of macro packages, then your application style should do the 
following:

\ifthisiscontext
    \hookmycodeintothecontextcallbackhandler
\else\ifthislatex
    \hookmycodeintothelatexcallbackhandler
\else
    \loadmycodeintomyowncallbackhandler
    \hookmycodeintomyowncallbackhandler
\fi\fi

this approach is the same as for styles (packages) that use specials, or 
specific pdftex features, or ...

i hope that this explains it a bit

Hans




-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list