Hi guys, I'm busy working on translating ppcmd formatting to webviews. I have a question that might be quite dumb but maybe you can enlighten me:
What is the purpose of ppcmd_glue ? Or actually better question: is there any possibility for a ppcmd_box to have any other child than a ppcmd_glue ? I don't see what the purpose of a box with single PpString would do, and the only way to have several would be to use a Ppcmd_glue ? Or maybe with a ppcmd_comment (but that is just a string list so no breaks...) ? Why not then make it that the ppcmd_box just accepts a list of pp_cmd ? It would make things way more legible and convenient !
ppcmd_glue is the concatenation operator ++
ppcmds are typically produced with code looking like hov 2 (str "foo" ++ spc() ++ pr_bar bar)
where pr_bar may eg generate more glue
hov
generates a ppcmd_box
I don't see how making ppcmd_box take a list of ppcmds would make things nicer
note that glue is not eagerly flattened (that's costly) so you can get eg glue [glue [foo;bar]; glue [baz;bli]]
okay maybe I just don't fully understand the format. Would an embedded break in a box still work ? Say you have
box[ glue [glue [foo; break; bar]; glue [baz;bli]] ]
would that break hint still count for the original box ?
Gaëtan Gilbert said:
[...]
I don't see how making ppcmd_box take a list of ppcmds would make things nicer
I just don't understand what would be the function of a box with a singleton ? Because my understanding is that the main importance of a box is allowing for breaks to happen, which it can't happen with a singleton ? Unless you answer yes to my previous question
Say you have
box[ glue [glue [foo; break; bar]; glue [baz;bli]] ] would that break hint still count for the original box ?
yes
okay but then the only two solutions which make sense as a direct child of a box would be a glue or a tag ? Cause otherwise you can't have a break. Am I getting that right ?
because it's dynamically generated it's possible to get anything
for instance you might get something like hov 2 (pr_foo foo)
where pr_foo
sometimes produces str "x"
and sometimes has breaks
I understand from the types that it is possible, I just don't see why you would want to do it ? Unless it can change dynamically ! Meaning a visual representation of a box will suddenly gain new children, but it doesn't seem to me you would need such a dynamic representation ?
Last updated: Oct 13 2024 at 01:02 UTC