Live data from Hacker News

Lambda Operator in LaTeX

commutative.xyz

21–23 of 23 posts

Re: Lambda Operator in LaTeX

#21
post #16

Earlier quoted context omitted.

I'll agree that not the posted article but your comment does sum up the way many users experience LaTeX (without taking a few minutes to understand what's going on), and it's interesting to think about what factors of TeX/LaTeX and its documentation/ecosystem lead to this outcome. About the posted article: if all one wanted to do was "typeset this bit of common math", one can just type "\lambda x.(2x)" in math mode.…

It's true, I do enjoy being perverse. However, I think it's a bit unfair to say I have "picked up a few pieces of knowledge, become excited, and tried to hack their way through by themselves, without understanding the broader ecosystem of other packages and conventions". I'm aware of xparse, and other tools in the ecosystem (etoolbox, ifthenelse). This doesn't mean that I shouldn't try to get a given result with the…

Yes fair! Sorry about that; I was focused on the comment I was replying to and forgot about being fair to you; I've now edited my post to change "without understanding" to "without bothering to integrate with" (and some other changes); hope it reads better now!

And as I said, doing things one's own way with the primitives is perfectly fine… I too have participated in my share of TeX perversity and doing things it wasn't designed for (example: https://tex.stackexchange.com/a/403353); I guess it's one of the things that attracts people like us to such an old system. :-)

Re: Lambda Operator in LaTeX

#22
post #21

Earlier quoted context omitted.

It's true, I do enjoy being perverse. However, I think it's a bit unfair to say I have "picked up a few pieces of knowledge, become excited, and tried to hack their way through by themselves, without understanding the broader ecosystem of other packages and conventions". I'm aware of xparse, and other tools in the ecosystem (etoolbox, ifthenelse). This doesn't mean that I shouldn't try to get a given result with the…

Yes fair! Sorry about that; I was focused on the comment I was replying to and forgot about being fair to you; I've now edited my post to change "without understanding" to "without bothering to integrate with" (and some other changes); hope it reads better now! And as I said, doing things one's own way with the primitives is perfectly fine… I too have participated in my share of TeX perversity and doing things it was…

Re. 403353: That's a lovely stackexchange post, and inspiring; I've run into it more than once when googling for answers. Great running into you here, and thanks for caring enough to rephrase the post.

Re: Lambda Operator in LaTeX

#23
post #11

You don't have to define `\First` and `\Second` since these are predefined as `\@firstoftwo` and `\@secondoftwo`. Also the Unicode bytes are already active so setting their catcode is useless. Also redefining the first octet breaks LaTeX's UTF-8 handling and the else case forms an infinite loop. Changing the catcodes of `(` and `)` means that this command doesn't work in the arguments of other commands and it breaks…

Thanks, and ouch. I have some follow-up questions/comments, if you have the time: > these are predefined as `\@firstoftwo` and `\@secondoftwo` I do wish LaTeX kernel commands (which I'm assuming these are) were more widely documented. As it stands, it's pretty hard to keep track of what already exists. Is there a nice reference for those? > Also the Unicode bytes are already active so setting their catcode is useless…

> I do wish LaTeX kernel commands (which I'm assuming these are) were more widely documented. As it stands, it's pretty hard to keep track of what already exists. Is there a nice reference for those?

Not really, the traditional commands are rather messy. Of course you can read source2e, but that's not really documentation. For new stuff it often makes sense to write the more programmy stuff in expl3 which is much better documented in interface3. (It contains these commands as `\use_i:nn` and `\use_ii:nn`)

> > Also the Unicode bytes are already active so setting their catcode is useless. > > This is true for LaTeX and not TeX, correct?

Right, this is LaTeX specific.

> Also redefining the first octet breaks LaTeX's UTF-8 handling... > > How so? (If the else case wasn't broken)

LaTeX's definition of the first byte handles arbitrary valid UTF-8 following bytes by using corresponding definitions or printing correct errors, while even a definition which wouldn't trigger the active character again would just print the two bytes which does not print a useful error message and probably prints two random characters from the font, completely ignoring any potential definition using LaTeX's mechanism for other codepoints starting with this byte.

>...and the else case forms an infinite loop. > > If `\Firstλ` was not an active character, would this still be true? Since I store `\Firstλ` in `\lambda@first@oct` before it's declared an active character.

You are correct, if the first byte wouldn't already be an active character (e.g. in plain TeX) then it wouldn't loop. It wouldn't expand to something particularly useful, but that wouldn't be any worse than without the definition so it would be "correct".

> I suppose I should read up on xparse.

Normally `xparse` is preloaded and not a package anymore, therefore also it's documentation has been moved into usrguide3. In this case you still need the package though since the `d` argument type has not been added to the kernel (and therefore also not to usrguide3) since delimited arguments are not recommended for LaTeX commands. It's still documented in the old `xparse` manual though. Just in case you're wondering about the split.

Post reply on HN