Hi, 
 
i want to propose two new primitives for LuaTeX: 
 
- The existing `\luafunction` has some similarities to `\count`, `\dimen`, 
`\skip`. Especially for most use cases, you will have to allocate a number, but 
there is no equivalent to `\countdef` etc. 
   I think LuaTeX would benefit from `\luafunctiondef`, such that e.g. 
`\luafunctiondef\something1` would define `\something`, such that `\something` 
is equivalent to `\luafunction1`. 
  What is the difference to creating a regular macro? This would allow 
`\something` to be expandable in a single step, which is especially important 
for emulating primitives from other engines with lua code. 
 
- Additionally it would be useful to allow "expandable temporary macro 
definitions". So for example 
 
    \scantexmacro#1#2\stop{-#1-#2-}abc\stop def 
 
  would expand to 
 
    -a-bc-def 
 
  This allows using the TeX macro argument parser inside expandable macros, 
especially when the delimiter can change. For example if you implement a 
property list as `\@key key1\@value value1\@key key2\@value value2...`, you can 
create an expandable macro to ge the value of key `#2` without requiring 
recursive calls with 
 
    \def\propget#1#2{% 
      \scantexmacro##1\@key#2\@value##2\@key##3\stop{% 
        ##2% 
      }#1\@key#2\@value\@key\stop 
    }  
 
  Another use-case would be implementingan expandable version of functionality 
similar to the expl3 `\seq_map_inline:Nn`. 
 
What do think? Is there any chance to see something like this in LuaTeX?
I attached a first implementation as patch against the current experimental 
branch.

Best regards 
Marcel Krüger

Attachment: 0001-Add-luafunctiondef.patch
Description: Binary data

Attachment: 0002-Add-scantexmacro.patch
Description: Binary data

_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-luatex

Reply via email to