4

What do you think about mixing expl3 and luacode? Is this an "accepted approach" or rather a "bad practise" or something in between?

Consider, for example, my previous question Nested splitting of a sequence using expl3 and the excellent answers by egreg and Mico. I have started writing a package based on expl3. In this specific case, however, the LuaTeX solution is much more concise. This is why I would tend to call a LuaTeX function from an expl3 function.

  • 3
    nothing wrong with mixing lua and expl3 so long as you are writing luatex-specific package code. Personally I find it easier to use \directlua than the wrappers provided by the luacode package, but opinions differ on that. – David Carlisle Nov 24 '17 at 9:44
  • 2
    @DavidCarlisle It's unfortunately really hard to get % and # in Lua without the help of the luacode package. I asked Joseph whether I should write something similar for expl3 but he declined. – Henri Menke Nov 24 '17 at 10:12
  • not really hard (If we don't already provide macros holding % (ie \@percentchar and # you could easily define them. – David Carlisle Nov 24 '17 at 10:15
  • 1
    One of the goals of expl3 is having a basis that provides (fairly) decent programming constracts that actually work more or less seemlessly across different engines (and in fact can work across different formats). If you mix in Lua code then you loose that feature, ie that your package does work with both LuaTeX and pdfTeX --- so it depends on what you want/need and which user base should be able to use it afterwards. As to what we are eventually going to provide there in terms of "official" support that is still a bit further down in the future, so we aren't yet zooming in on one interface. – Frank Mittelbach Nov 25 '17 at 17:58
  • 1
    I suppose an important factor in the "expl3 or Lua code" debate is your personal, prior familiarity with expl3- and Lua-based programming. Speaking purely for myself, I find Lua-based programming fairly easy to do -- at least for the stuff I need to get done in my own papers. This, in turn, is mainly (entirely?!) the case because I was already familiar with Lua and because the "hooks" provided by Lua(La)TeX (the \directlua macro and the machinery of the luacode package) are rather straightforward and easy to master. Naturally, other people's mileage with Lua may (and will surely) vary. – Mico Nov 28 '17 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.