John Snow <js...@redhat.com> writes: > On 9/18/20 6:33 AM, Markus Armbruster wrote: >> John Snow <js...@redhat.com> writes: [...] >>> Embedded templates are always gonna look kinda nasty, I think, because >>> you're trying to fight style guidelines in two languages >>> simultaneously and it's never gonna quite work out exactly how you >>> want without some pretty complex abstraction mechanisms that are well >>> beyond the power we need right now. >> The thought "screw this, pile the output through /usr/bin/indent" >> has >> crossed my mind more than once. >> > > Bigger fish to fry, but with other languages like rust looming, making > the core generation facilities nicer might be ...nice. Not for this > series.
Definitely not. The way we generate C now is (close to) the stupidest way that could possibly work. Stupid is *good*, until it creates actual problems. Any improvement will have to balance readability vs. hackability. What we have now is often hard to read, but pretty easy to hack. May sound like a contradiction, but it's been my experience. > Two approaches in general would make sense to me: > > 1. Building an AST for C instead of strings, and rendering the AST. I fear the need to define an AST for C makes this uneconomical. I've missed the ease of generating Lisp in Lisp many times. > 2. Writing a templating engine that doesn't break the Python > indentation flow by hoisting them into module constants and improving > the rendering logic. Too vague for me to judge, happy to look at PoC patches.