An Ubuntu kernel bug causes container crashes
An Ubuntu kernel bug causes container crashes
Posted Jul 7, 2022 8:52 UTC (Thu) by bartoc (guest, #124262)In reply to: An Ubuntu kernel bug causes container crashes by developer122
Parent article: An Ubuntu kernel bug causes container crashes
This ends up going a _little_ better than you would expect, but not much.
You can do cocci style semantic diff and merge, where the merge is based on the AST, not the text. But this means you need to parse everything perfectly and it's not that much better than a good text-based diff/merge algorithm. I suppose in a way this is what __attribute__((flatten)) or always_inline do.
Actually it would be kinda neat to have a compiler plugin or extension that let you inject code "somewhere else". You could have a compiler plugin that let you write functions to be injected at specific locations. This would be merely "neat" for these kinds of functionality patches but I think it could actually be a useful feature for injecting static tracepoints without cluttering up the code too much (or forgetting to add one someplace).
Come to think of it nim-lang has an experimental feature for this called "term rewriting macros", you can write something like (from the manual):
template optMul{`*`(a, 2)}(a: int): int = a+a
once this is brought into scope the compiler will rewrite any further expressions like some_ident * 2 as some_ident * some_ident. You can see how this is basically a megaton yield footgun. The matching language is kinda neat, but it's very sensitive to the exact structure of the AST, so it can miss stuff (nim has macros too, but these operate on a kind of alternate "stable" ast that converts too and from the "real" AST. That's harder for TR macros because any change in the "real" ast is usually something TR macros might be interested in, or might be able to break if they don't understand.
Because of these issues, and because TR macros are not widely used, and because they have some performance problems they may be removed.
Oh Mathamatica's "Wolfram Language" is famously based on this concept, and there is a lot of literature out there about how amazing it is. I remain unconvinced, but it is unconventional and interesting for sure.
Oh, you can imagine that once you have such a facility and multiple users pop up trying to use it at once things get quite interesting quite fast.
