-
Notifications
You must be signed in to change notification settings - Fork 178
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
l3keys isn't align safe #896
Comments
There are a few possible fixes for this. The following implements a few of them as an MWE and runs some test to show in which cases the respective fix would actually work.
I'm wary which of these is the way to go, and I honestly don't understand why the first fix (only one align-safe group around everything) fails if the user provided code (in this case When it is decided to use the third fix (using |
Also, if the fourth fix (delaying output) is chosen, we could reorder much of the internals of |
Explanation why the first proposed fix doesn't work is no longer needed, that's actually contained in a footnote of the TeXbook:
|
I'm not sure that we have to fix this, we could just document it. This variant of the original test document runs without error
Here the calling code has already used a I think in most cases where a keyval parser is used in an alignment the same will be true, it will be vanishingly rare that a document level command occurring in an alignment needs to expand straight into key parsing with no possibility of adding any guards. Perhaps the main example would be a version of \multicolumn taking a kv argument but if such a command has to take special precautions I don't think that's too bad, if making the general fix has an adverse effect on the speed and maintainability of the parsing in all the normal cases. |
I disagree with David here. The typical package writer will not think of
putting \iffalse{\fi constructions in the right places.
(sorry, typing with 1 hand only)
|
I agree with @davidcarlisle in part. It is trivial to make The typical package writer will use So it might really be a good idea to document |
Also the use case with an expandable key=value macro that should expand to Does anyone have another good use case that really requires |
they might think of it if we documented it was needed, but my point is that in most cases where it matters they probably need to have done this already, the keyval parsing is typically embedded in some command definition and you need to have the guards higher up when you grab the arguments. If in the end we come up with a fix that isn't over contorted or have too great an impact in the common case where it isn't needed then yes we should add it but otherwise it isn't clearly a win, I think. |
@david: "probably need to have done this already [...] need to have the guards
higher up when you grab the arguments" → That's not true because in
\def\mycommand#1{\keyval_parse:NNn \my:n \my:nn {#1}}
\halign{#\cr
\mycommand{foo=&,bar}}
the & is properly hidden by the braces, until we reach the internals of
\keyval_parse:NNn. From the package author's point of view it seems that #1 is
always properly hidden by braces so things should be align-safe.
I quite like the third fix \unexpanded\expanded{{...}}.
In engines without \expanded I like the second fix (opening/closing the
group_align_safe at each user code). Is there a reason to prefer the fourth fix
(collecting everything until the end) compared to the second?
|
We could reduce code complexity with the fourth (no forwarding of the user code through all levels needed). It is guaranteed to be stable. And it is guaranteed to be f-expandable just like the I'll run a few small benchmarks next week with the three candidates. Then we can make an educated decision. |
I don't think you should spend time on the fix number four because it will be prohibitively slow (quadratic in the number of keyval entries) and we have many other restricted-expandable commands of the same kind: I view Maybe when |
I've gone for fix number 2 even when |
@blefloch I don't think it would've been too messy to implement both fixes in parallel, and the |
Thanks. Sorry, I was a bit lazy about that. |
The underlying
\keyval_parse:NNn
ofl3keys
isn't alignment safe if the key=value list contains an alignment character outside of braces.The text was updated successfully, but these errors were encountered: