Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TeX-like "def" macro doesn't allow inverting the arguments order (a.k.a. "overset" not supported) #2133

Open
Omikhleia opened this issue Oct 16, 2024 · 2 comments
Labels
bug Software bug issue

Comments

@Omikhleia
Copy link
Member

Omikhleia commented Oct 16, 2024

Formula:

\def{overset}{\munderover{#2}{}{#1}}
R^n \overset{A}{→} R^m

This issue should have been a proposal: "Let's support TeX-like \overset which is a nice convenience"... and here would have been expected to produce the arrow with a smaller A on top of it... and surely a simple macro is enough, right?

... But the above crashes with "Wrong number of arguments (2) for command overset (should be 1)"

Extra test: as in the code, fractions are defined as \def{frac}{\mfrac{#2}{#1}} and \frac{x}{y} gives x / y...
Let's try \def{invfrac}{\mfrac{#2}{#1}} and expecting it to be produce y / x...
Same failure as above.

So we have these def-macro thing "to save (us) some typing"...
How can we achieve \overset? "When macros are not enough, creating new mathematical elements is quite simple" (... followed by lots of not-so-simple explanation for a newcomer). Sure. It's typically a case where a macro would have been neat, though.

🌵 My dear math friends, yes, again... Will you start to typeset some real maths one day? Just askin'

Subsidiary remark: Nowhere does the documentation says how little of the TeX-like math syntax1 is currently supported... and if there are any real goals in making it more complete.... But the reality check leads to serious doubts... 😬

Footnotes

  1. Read "commands". But you got the point.

@Omikhleia Omikhleia added the bug Software bug issue label Oct 16, 2024
@Omikhleia Omikhleia added this to Math Oct 16, 2024
@github-project-automation github-project-automation bot moved this to To do in Math Oct 16, 2024
@Omikhleia Omikhleia changed the title TeX-like "def" macro doesn't allow inversing the order of arguments (a.k.a. "overset" is not supported) TeX-like "def" macro doesn't allow inverting the arguments order (a.k.a. "overset" not supported) Oct 16, 2024
@Omikhleia
Copy link
Member Author

Omikhleia commented Oct 17, 2024

To make it clear, the goal here would be to support TeX math \overset and \underset (and possibly too \stackrel)

Subsidiary question: How to have them considered as relations.

Additional reference:

https://github.com/jgm/texmath/blob/4315006320ea7119fb1c1a1ca5aaf755b0a2bff7/src/Text/TeXMath/Readers/TeX.hs#L745-L755

@Omikhleia
Copy link
Member Author

Omikhleia commented Nov 2, 2024

Very interesting 🤣

I think the problem is here:

table.insert(ret, body.index, typeRequired)

(Unordered arguments won't be were expected).

(1) But the solution is not only to change that ugly code1 to ret[body.index] = typeRequired: if there are unused arguments, you'd end up with a sparse table, and #-counting elements will fail...

(2) Or will it? Yes sure, except if one is lucky with only two arguments. I think I found a bug in LuaJIT... Eek?

Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> t = {}; t[2]="test"; print("Len=", #t);
Len=	0
SILE v0.15.5 (LuaJIT 2.1.1727870382) [Rust]
> t = {}; t[2]="test"; print("Len=", #t);
Len=	2

Footnotes

  1. Really bad coding in this inferArgTypes_aux function: 1. dirty mix of early return's and elseif's 2. unclear purpose, no doc hint nor exploitable signature for one to assume what were the intents, 3. deep recursion with an accumulator "of things unknown", a call for losing all predictability without noticing. And yes, @OlivierNicole one can criticize the code, and it's not ad hominem, it's just... bad code, as it happens to all of us. It's a call for improving it. Whatever the language (so Lua be it here), the programmer is the one who wandered off tracks here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software bug issue
Projects
Status: To do
Development

No branches or pull requests

2 participants
@Omikhleia and others