Ternary expression?
Ternary expression?
Posted Sep 30, 2024 23:29 UTC (Mon) by Paf (subscriber, #91811)Parent article: Coccinelle for Rust
println!("{}", if boolean { "string 1" } else { "string 2" })
Different from:
printf(“%s”, boolean ? String 1 : string 2)
?
Posted Oct 1, 2024 6:38 UTC (Tue)
by milian.wolff (guest, #153128)
[Link] (4 responses)
Posted Oct 1, 2024 13:34 UTC (Tue)
by Paf (subscriber, #91811)
[Link] (3 responses)
So the particular example is perhaps poorly chosen as it has an extremely close equivalent in C.
Posted Oct 1, 2024 13:44 UTC (Tue)
by daroc (editor, #160859)
[Link] (2 responses)
Posted Oct 2, 2024 11:29 UTC (Wed)
by khim (subscriber, #9252)
[Link]
We are not talking arbitrary C code, though, we are talking about kernel. In Linux kernel, of course, it's not just possible, it's routine, there are many macros that exploit that ability.
Posted Oct 3, 2024 14:16 UTC (Thu)
by Paf (subscriber, #91811)
[Link]
Posted Oct 1, 2024 8:38 UTC (Tue)
by danielthompson (subscriber, #97243)
[Link]
I suspect part of the concern is also that, by allowing coccinelle to recognise the if in the println!() macro, will also result in it having to test many, many other control flow expressions for matches which would have been ignored when they appear in C.
Posted Oct 1, 2024 11:48 UTC (Tue)
by kaesaecracker (subscriber, #126447)
[Link]
Ternary expression?
Ternary expression?
Ternary expression?
> Maybe it would help to point out that in Rust you can have things like while loops inside if expressions, which isn't really possible with C ternary expressions.
Ternary expression?
Ternary expression?
Ternary expression?
Ternary expression?
