* [cocci] Reducing parentheses (with SmPL)? @ 2025-07-19 12:04 Markus Elfring 2025-07-19 19:16 ` Julia Lawall 0 siblings, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-19 12:04 UTC (permalink / raw) To: cocci Hello, Some information is provided also according to the question “How to remove useless parentheses?” in the documentation of the semantic patch language. https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/2548098a0c8b148555f4bf11a12898ecaf023dea/docs/manual/tips.tex#L6-41 Another corresponding file contains a todo tag. https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/2548098a0c8b148555f4bf11a12898ecaf023dea/standard.iso#L382-397 It seems that some conditions should be reconsidered. I would occasionally like to capture detailed expression code by metavariables. I am unsure about the properties of the found expressions which should be reused somehow. Thus I would tend to enclose such data by extra parentheses. A manual inspection would indicate then for an adjusted code place that this addition would occasionally be redundant. Can this aspect be better supported automatically? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-19 12:04 [cocci] Reducing parentheses (with SmPL)? Markus Elfring @ 2025-07-19 19:16 ` Julia Lawall 2025-07-20 7:21 ` Markus Elfring 0 siblings, 1 reply; 26+ messages in thread From: Julia Lawall @ 2025-07-19 19:16 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci [-- Attachment #1: Type: text/plain, Size: 1127 bytes --] On Sat, 19 Jul 2025, Markus Elfring wrote: > Hello, > > Some information is provided also according to the question “How to remove > useless parentheses?” in the documentation of the semantic patch language. > https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/2548098a0c8b148555f4bf11a12898ecaf023dea/docs/manual/tips.tex#L6-41 > > Another corresponding file contains a todo tag. > https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/2548098a0c8b148555f4bf11a12898ecaf023dea/standard.iso#L382-397 > > It seems that some conditions should be reconsidered. > > I would occasionally like to capture detailed expression code by metavariables. What conditions? What detailed expression code? It is not possible to understand this without more information. julia > I am unsure about the properties of the found expressions which should be reused somehow. > Thus I would tend to enclose such data by extra parentheses. > A manual inspection would indicate then for an adjusted code place that this > addition would occasionally be redundant. > Can this aspect be better supported automatically? > > Regards, > Markus > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-19 19:16 ` Julia Lawall @ 2025-07-20 7:21 ` Markus Elfring 2025-07-20 14:10 ` Julia Lawall 0 siblings, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-20 7:21 UTC (permalink / raw) To: Julia Lawall, cocci >> Another corresponding file contains a todo tag. >> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/2548098a0c8b148555f4bf11a12898ecaf023dea/standard.iso#L382-397 How do you think about to discuss corresponding imaginations? >> It seems that some conditions should be reconsidered. >> >> I would occasionally like to capture detailed expression code by metavariables. > > What conditions? I came also along recurring development concerns according to selected source code transformations. > What detailed expression code? The complexity can vary for found expressions, can't it? > It is not possible to > understand this without more information. …>> I am unsure about the properties of the found expressions which should be reused somehow. >> Thus I would tend to enclose such data by extra parentheses. >> A manual inspection would indicate then for an adjusted code place that this >> addition would occasionally be redundant. >> Can this aspect be better supported automatically? Will any information from this clarification approach get more attention? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-20 7:21 ` Markus Elfring @ 2025-07-20 14:10 ` Julia Lawall 2025-07-20 18:08 ` Markus Elfring 2025-07-21 5:30 ` Markus Elfring 0 siblings, 2 replies; 26+ messages in thread From: Julia Lawall @ 2025-07-20 14:10 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci [-- Attachment #1: Type: text/plain, Size: 1520 bytes --] On Sun, 20 Jul 2025, Markus Elfring wrote: > >> Another corresponding file contains a todo tag. > >> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/2548098a0c8b148555f4bf11a12898ecaf023dea/standard.iso#L382-397 > > How do you think about to discuss corresponding imaginations? Te TODO has to do with sizeof. Why is it relevant to the general problem of reducing parentheses? It's not clear whether you want to reduch parentheses in the semantic patch (the only thing that is affected by an isomorphism) or in the C code. julia > > > >> It seems that some conditions should be reconsidered. > >> > >> I would occasionally like to capture detailed expression code by metavariables. > > > > What conditions? > > I came also along recurring development concerns according to selected > source code transformations. > > > > What detailed expression code? > > The complexity can vary for found expressions, can't it? > > > > It is not possible to > > understand this without more information. > …>> I am unsure about the properties of the found expressions which should be reused somehow. > >> Thus I would tend to enclose such data by extra parentheses. > >> A manual inspection would indicate then for an adjusted code place that this > >> addition would occasionally be redundant. > >> Can this aspect be better supported automatically? > > Will any information from this clarification approach get more attention? > > Regards, > Markus > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-20 14:10 ` Julia Lawall @ 2025-07-20 18:08 ` Markus Elfring 2025-07-21 5:30 ` Markus Elfring 1 sibling, 0 replies; 26+ messages in thread From: Markus Elfring @ 2025-07-20 18:08 UTC (permalink / raw) To: Julia Lawall, cocci > It's not clear whether you want to reduch parentheses in the semantic > patch (the only thing that is affected by an isomorphism) or in the C code. I imagine that expression properties should be taken better into account for both application domains. How may an expression look like so that parentheses can be omitted? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-20 14:10 ` Julia Lawall 2025-07-20 18:08 ` Markus Elfring @ 2025-07-21 5:30 ` Markus Elfring 2025-07-21 5:48 ` Julia Lawall 1 sibling, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-21 5:30 UTC (permalink / raw) To: Julia Lawall, cocci > It's not clear whether you want to reduch parentheses in the semantic > patch (the only thing that is affected by an isomorphism) or in the C code. We got used to the order of operations to some degree. https://en.wikipedia.org/wiki/Order_of_operations https://en.cppreference.com/w/c/language/value_category.html How will the support evolve further for safe transformations of expressions? The entity “expression” is supported by the semantic patch language in a limited way so far. It is mapped to a single metavariable type. Metavariables matter at different places. * They can match some source code from context (or minus slice) specifications. * Metavariable contents can be reused for plus slice specifications. Desirable source code adjustments should be “expressed” here. Which control can we get on the advanced handling of parentheses then? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 5:30 ` Markus Elfring @ 2025-07-21 5:48 ` Julia Lawall 2025-07-21 6:30 ` Markus Elfring 0 siblings, 1 reply; 26+ messages in thread From: Julia Lawall @ 2025-07-21 5:48 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci [-- Attachment #1: Type: text/plain, Size: 1288 bytes --] On Mon, 21 Jul 2025, Markus Elfring wrote: > > It's not clear whether you want to reduch parentheses in the semantic > > patch (the only thing that is affected by an isomorphism) or in the C code. > > We got used to the order of operations to some degree. > > https://en.wikipedia.org/wiki/Order_of_operations > https://en.cppreference.com/w/c/language/value_category.html > > > How will the support evolve further for safe transformations of expressions? > > The entity “expression” is supported by the semantic patch language in > a limited way so far. > It is mapped to a single metavariable type. Metavariables matter at different places. > > * They can match some source code from context (or minus slice) specifications. > > * Metavariable contents can be reused for plus slice specifications. > Desirable source code adjustments should be “expressed” here. > Which control can we get on the advanced handling of parentheses then? I have no idea what you are trying to do, and you are never going to succeed with your strange way of expressing yourself. If you want to know how to do something, please provide a concrete and minimal example of C code and show what you would like it to be transformed into. That is the only thing I can precisely understand. julia ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 5:48 ` Julia Lawall @ 2025-07-21 6:30 ` Markus Elfring 2025-07-21 6:46 ` Julia Lawall 0 siblings, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-21 6:30 UTC (permalink / raw) To: Julia Lawall, cocci >> * Metavariable contents can be reused for plus slice specifications. >> Desirable source code adjustments should be “expressed” here. >> Which control can we get on the advanced handling of parentheses then? > > I have no idea what you are trying to do, I find such feedback strange. > and you are never going to > succeed with your strange way of expressing yourself. I hope still that remaining communication difficulties can be resolved better. > If you want to know > how to do something, please provide a concrete and minimal example of C > code and show what you would like it to be transformed into. That is the > only thing I can precisely understand. Your public activities seem to indicate that you are capable for more. * We would occasionally like to transform selected expressions (which were captured by instances of the metavariable type “expression”), don't we? * Do we care then if it would be needed to specify extra parentheses (or not) for plus slice specifications? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 6:30 ` Markus Elfring @ 2025-07-21 6:46 ` Julia Lawall 2025-07-21 6:58 ` Markus Elfring 0 siblings, 1 reply; 26+ messages in thread From: Julia Lawall @ 2025-07-21 6:46 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci [-- Attachment #1: Type: text/plain, Size: 1224 bytes --] On Mon, 21 Jul 2025, Markus Elfring wrote: > >> * Metavariable contents can be reused for plus slice specifications. > >> Desirable source code adjustments should be “expressed” here. > >> Which control can we get on the advanced handling of parentheses then? > > > > I have no idea what you are trying to do, > > I find such feedback strange. > > > > and you are never going to > > succeed with your strange way of expressing yourself. > > I hope still that remaining communication difficulties can be resolved better. > > > > If you want to know > > how to do something, please provide a concrete and minimal example of C > > code and show what you would like it to be transformed into. That is the > > only thing I can precisely understand. > > Your public activities seem to indicate that you are capable for more. > > * We would occasionally like to transform selected expressions > (which were captured by instances of the metavariable type “expression”), > don't we? Yes. > * Do we care then if it would be needed to specify extra parentheses (or not) > for plus slice specifications? No. julia ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 6:46 ` Julia Lawall @ 2025-07-21 6:58 ` Markus Elfring 2025-07-21 7:45 ` Julia Lawall 0 siblings, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-21 6:58 UTC (permalink / raw) To: Julia Lawall, cocci >> * We would occasionally like to transform selected expressions >> (which were captured by instances of the metavariable type “expression”), >> don't we? > Yes. Thanks for an agreement on this use case. >> * Do we care then if it would be needed to specify extra parentheses (or not) >> for plus slice specifications? > No. I interpret this feedback in the way that it indicates another communication difficulty. I am trying to develop adjustments that are consistent and modify source code places in a minimal and required way. I find the influence of the data handling for parentheses important somehow. Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 6:58 ` Markus Elfring @ 2025-07-21 7:45 ` Julia Lawall 2025-07-21 7:55 ` Markus Elfring 0 siblings, 1 reply; 26+ messages in thread From: Julia Lawall @ 2025-07-21 7:45 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci [-- Attachment #1: Type: text/plain, Size: 811 bytes --] On Mon, 21 Jul 2025, Markus Elfring wrote: > >> * We would occasionally like to transform selected expressions > >> (which were captured by instances of the metavariable type “expression”), > >> don't we? > > Yes. > > Thanks for an agreement on this use case. > > > >> * Do we care then if it would be needed to specify extra parentheses (or not) > >> for plus slice specifications? > > No. > > I interpret this feedback in the way that it indicates another communication difficulty. > > I am trying to develop adjustments that are consistent and modify source code > places in a minimal and required way. > I find the influence of the data handling for parentheses important somehow. If you have some concrete problems please provide those concrete problems rather than vague descriptions. julia ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 7:45 ` Julia Lawall @ 2025-07-21 7:55 ` Markus Elfring 2025-07-21 7:58 ` Julia Lawall 0 siblings, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-21 7:55 UTC (permalink / raw) To: Julia Lawall, cocci >> I am trying to develop adjustments that are consistent and modify source code >> places in a minimal and required way. >> I find the influence of the data handling for parentheses important somehow. > If you have some concrete problems please provide those concrete problems > rather than vague descriptions. Would you find it really easier to clarify known data processing challenges with the help of another SmPL script example? @display@ expression e; statement x, y; @@ if ( * e ) x else y Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 7:55 ` Markus Elfring @ 2025-07-21 7:58 ` Julia Lawall 2025-07-21 8:10 ` Markus Elfring 2025-07-21 9:51 ` Markus Elfring 0 siblings, 2 replies; 26+ messages in thread From: Julia Lawall @ 2025-07-21 7:58 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci On Mon, 21 Jul 2025, Markus Elfring wrote: > >> I am trying to develop adjustments that are consistent and modify source code > >> places in a minimal and required way. > >> I find the influence of the data handling for parentheses important somehow. > > If you have some concrete problems please provide those concrete problems > > rather than vague descriptions. > > Would you find it really easier to clarify known data processing challenges > with the help of another SmPL script example? I at least understand th script. But I don't kjnow what problem does it raise? julia > > > @display@ > expression e; > statement x, y; > @@ > if ( > * e > ) > x > else > y > > > Regards, > Markus > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 7:58 ` Julia Lawall @ 2025-07-21 8:10 ` Markus Elfring 2025-07-21 8:23 ` Julia Lawall 2025-07-21 9:51 ` Markus Elfring 1 sibling, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-21 8:10 UTC (permalink / raw) To: Julia Lawall, cocci >> Would you find it really easier to clarify known data processing challenges >> with the help of another SmPL script example? > I at least understand th script. But I don't kjnow what problem does it raise? …>> @display@ >> expression e; >> statement x, y; >> @@ >> if ( >> * e >> ) >> x >> else >> y Repetition: Would we occasionally like to put the found expression as a subitem into another SmPL plus slice specification? Will additional parentheses become relevant then (or not)? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 8:10 ` Markus Elfring @ 2025-07-21 8:23 ` Julia Lawall 2025-07-21 8:45 ` Markus Elfring 0 siblings, 1 reply; 26+ messages in thread From: Julia Lawall @ 2025-07-21 8:23 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci [-- Attachment #1: Type: text/plain, Size: 1016 bytes --] On Mon, 21 Jul 2025, Markus Elfring wrote: > >> Would you find it really easier to clarify known data processing challenges > >> with the help of another SmPL script example? > > I at least understand th script. But I don't kjnow what problem does it raise? > …>> @display@ > >> expression e; > >> statement x, y; > >> @@ > >> if ( > >> * e > >> ) > >> x > >> else > >> y > > Repetition: > Would we occasionally like to put the found expression as a subitem > into another SmPL plus slice specification? I don't know what we would occasionally like to do. I don't know what specific plus slice specification you are referring to. Precedence with respect to arithmetic operators is handled. If you have some other concern in mind please make a concrete example that shows the problem. I can't guess what you think someone might occasionally like to do. > Will additional parentheses become relevant then (or not)? How about actually trying something and seeing what is the result? julia ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 8:23 ` Julia Lawall @ 2025-07-21 8:45 ` Markus Elfring 0 siblings, 0 replies; 26+ messages in thread From: Markus Elfring @ 2025-07-21 8:45 UTC (permalink / raw) To: Julia Lawall, cocci >> Would we occasionally like to put the found expression as a subitem >> into another SmPL plus slice specification? > I don't know what we would occasionally like to do. Some SmPL script developers (and users) would like to recombine expressions, don't they? > I don't know what > specific plus slice specification you are referring to. You are familiar with data processing attempts which can be expected there. > Precedence with > respect to arithmetic operators is handled. Such information belongs to knowledge for expression properties, doesn't it? > If you have some other > concern in mind please make a concrete example that shows the problem. I got the impression that I see another need for the extension of supported metavariable types. >> Will additional parentheses become relevant then (or not)? > How about actually trying something and seeing what is the result? Corresponding software tests happened to some degree. I am unsure about the circumstances when the problem awareness and development resources will fit together better. Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 7:58 ` Julia Lawall 2025-07-21 8:10 ` Markus Elfring @ 2025-07-21 9:51 ` Markus Elfring 2025-07-21 11:00 ` Julia Lawall 1 sibling, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-21 9:51 UTC (permalink / raw) To: Julia Lawall, cocci >> Would you find it really easier to clarify known data processing challenges >> with the help of another SmPL script example? > I at least understand th script. But I don't kjnow what problem does it raise? Can you recognise development concerns better from another SmPL code variant? @adjustment@ expression e; statement s; @@ -if +my_result = (e) +&& true; - s Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 9:51 ` Markus Elfring @ 2025-07-21 11:00 ` Julia Lawall 2025-07-21 11:21 ` Markus Elfring 2025-07-22 7:33 ` Markus Elfring 0 siblings, 2 replies; 26+ messages in thread From: Julia Lawall @ 2025-07-21 11:00 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci On Mon, 21 Jul 2025, Markus Elfring wrote: > >> Would you find it really easier to clarify known data processing challenges > >> with the help of another SmPL script example? > > I at least understand th script. But I don't kjnow what problem does it raise? > > Can you recognise development concerns better from another SmPL code variant? > > > @adjustment@ > expression e; > statement s; > @@ > -if > +my_result = > (e) > +&& true; > - s And what is the problem? If you don't want the parentheses around e, then remove them. julai ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 11:00 ` Julia Lawall @ 2025-07-21 11:21 ` Markus Elfring 2025-07-21 11:54 ` Julia Lawall 2025-07-22 7:33 ` Markus Elfring 1 sibling, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-21 11:21 UTC (permalink / raw) To: Julia Lawall, cocci >> Can you recognise development concerns better from another SmPL code variant? >> >> >> @adjustment@ >> expression e; >> statement s; >> @@ >> -if >> +my_result = >> (e) >> +&& true; >> - s > And what is the problem? I would expect that further checks are needed for the determination if remaining parentheses can be redundant. I find the knowledge that is encapsulated by the metavariable type “expression” incomplete so far. > If you don't want the parentheses around e, then remove them. How would you determine if extra parentheses are actually required for a part of a recombined expression? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 11:21 ` Markus Elfring @ 2025-07-21 11:54 ` Julia Lawall 2025-07-21 12:14 ` Markus Elfring 2025-07-22 6:21 ` Markus Elfring 0 siblings, 2 replies; 26+ messages in thread From: Julia Lawall @ 2025-07-21 11:54 UTC (permalink / raw) To: Markus Elfring; +Cc: Julia Lawall, cocci [-- Attachment #1: Type: text/plain, Size: 882 bytes --] On Mon, 21 Jul 2025, Markus Elfring wrote: > >> Can you recognise development concerns better from another SmPL code variant? > >> > >> > >> @adjustment@ > >> expression e; > >> statement s; > >> @@ > >> -if > >> +my_result = > >> (e) > >> +&& true; > >> - s > > And what is the problem? > > I would expect that further checks are needed for the determination > if remaining parentheses can be redundant. > I find the knowledge that is encapsulated by the metavariable type “expression” > incomplete so far. > > > > If you don't want the parentheses around e, then remove them. > > How would you determine if extra parentheses are actually required > for a part of a recombined expression? The pretty printer looks at the context to some extent. If you have a concrete example that illustrates a problem, please provide it. If not, please end this discussion. julia ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 11:54 ` Julia Lawall @ 2025-07-21 12:14 ` Markus Elfring 2025-07-22 6:21 ` Markus Elfring 1 sibling, 0 replies; 26+ messages in thread From: Markus Elfring @ 2025-07-21 12:14 UTC (permalink / raw) To: Julia Lawall, cocci >> How would you determine if extra parentheses are actually required >> for a part of a recombined expression? > The pretty printer looks at the context to some extent. Would you like to document any special software behaviour accordingly? > If you have a > concrete example that illustrates a problem, please provide it. I hope still that the attention can grow also for the avoidance of superfluous parentheses. Can another information source become more interesting for such implementation details? https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es41-if-in-doubt-about-operator-precedence-parenthesize Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 11:54 ` Julia Lawall 2025-07-21 12:14 ` Markus Elfring @ 2025-07-22 6:21 ` Markus Elfring 1 sibling, 0 replies; 26+ messages in thread From: Markus Elfring @ 2025-07-22 6:21 UTC (permalink / raw) To: Julia Lawall, cocci >> How would you determine if extra parentheses are actually required >> for a part of a recombined expression? > The pretty printer looks at the context to some extent. If you have a > concrete example that illustrates a problem, please provide it. Would you dare to acknowledge consequences from (temporary) software limitations also for the discussed use case? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-21 11:00 ` Julia Lawall 2025-07-21 11:21 ` Markus Elfring @ 2025-07-22 7:33 ` Markus Elfring [not found] ` <479a2492-62de-2b9d-4899-4d4f35f653e9@inria.fr> 1 sibling, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-22 7:33 UTC (permalink / raw) To: Julia Lawall, cocci >> Can you recognise development concerns better from another SmPL code variant? >> >> >> @adjustment@ >> expression e; >> statement s; >> @@ >> -if >> +my_result = >> (e) >> +&& true; >> - s > And what is the problem? It is supported (to some degree by the means of the semantic patch language) to construct expressions for the usage within SmPL plus slice specifications. Developers can generally apply the design choice to use additional parentheses then. Some properties might be even unknown so far according to metavariable instances of the type “expression”. Programming interfaces can be extended accordingly. > If you don't want the parentheses around e, then remove them. There is a desire to avoid extra parentheses in the generated diff output. If such difference displays should be accepted as patches for known code bases, it would probably be more helpful if they could adhere better to coding style preferences. Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
[parent not found: <479a2492-62de-2b9d-4899-4d4f35f653e9@inria.fr>]
* Re: [cocci] Reducing parentheses (with SmPL)? [not found] ` <479a2492-62de-2b9d-4899-4d4f35f653e9@inria.fr> @ 2025-07-22 11:10 ` Markus Elfring 2025-07-22 11:12 ` Julia Lawall 0 siblings, 1 reply; 26+ messages in thread From: Markus Elfring @ 2025-07-22 11:10 UTC (permalink / raw) To: Julia Lawall, cocci >> There is a desire to avoid extra parentheses in the generated diff output. >> If such difference displays should be accepted as patches for known code bases, >> it would probably be more helpful if they could adhere better to coding >> style preferences. > You have sent like 20 messages about this. Some communication is obviously needed to achieve a better common understanding for the presented topic. > How about one single concrete > example where the output is not what you hoped for??? Another SmPL script example: @replacement@ expression condition, context, x, y; identifier action; @@ -if (condition) - { action(context, x); } -else - { action(context, y); } +action(context, (condition) ? (x) : (y)); Questionable test result (by the software combination “Coccinelle 1.3.0” for example): Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> git checkout next-20250722 && time /usr/bin/spatch …/Projekte/Coccinelle/Probe/use_selected_call_with_ternary_operator-20250722.cocci fs/xfs/scrub/findparent.c … @@ -229,11 +229,8 @@ xrep_findparent_live_update( … + xrep_findparent_scan_found(pscan, + (p->delta > 0) ? (p->dp->i_ino) : (NULLFSINO)); … @@ -269,10 +266,8 @@ __xrep_findparent_scan_start( … + xfs_dir_hook_setup(&pscan->dhook, + (custom_fn) ? (custom_fn) : (xrep_findparent_live_update)); … real 0m0,322s user 0m0,138s sys 0m0,022s > On the other hand, Coccinelle cannot guess what are your coding style preferences. It would be nice if the pattern recognition could be improved another bit. But we tend to concentrate mostly on Linux source code variations so far. Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-22 11:10 ` Markus Elfring @ 2025-07-22 11:12 ` Julia Lawall 2025-07-22 11:26 ` Markus Elfring 0 siblings, 1 reply; 26+ messages in thread From: Julia Lawall @ 2025-07-22 11:12 UTC (permalink / raw) To: Markus Elfring; +Cc: cocci [-- Attachment #1: Type: text/plain, Size: 1977 bytes --] On Tue, 22 Jul 2025, Markus Elfring wrote: > >> There is a desire to avoid extra parentheses in the generated diff output. > >> If such difference displays should be accepted as patches for known code bases, > >> it would probably be more helpful if they could adhere better to coding > >> style preferences. > > You have sent like 20 messages about this. > > Some communication is obviously needed to achieve a better common understanding > for the presented topic. > > > > How about one single concrete > > example where the output is not what you hoped for??? > > Another SmPL script example: > @replacement@ > expression condition, context, x, y; > identifier action; > @@ > -if (condition) > - { action(context, x); } > -else > - { action(context, y); } > +action(context, (condition) ? (x) : (y)); > > > Questionable test result (by the software combination “Coccinelle 1.3.0” for example): > Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> git checkout next-20250722 && time /usr/bin/spatch …/Projekte/Coccinelle/Probe/use_selected_call_with_ternary_operator-20250722.cocci fs/xfs/scrub/findparent.c > … > @@ -229,11 +229,8 @@ xrep_findparent_live_update( > … > + xrep_findparent_scan_found(pscan, > + (p->delta > 0) ? (p->dp->i_ino) : (NULLFSINO)); > … > @@ -269,10 +266,8 @@ __xrep_findparent_scan_start( > … > + xfs_dir_hook_setup(&pscan->dhook, > + (custom_fn) ? (custom_fn) : (xrep_findparent_live_update)); > … Why is it a surprise to see the () if you put the ()? julia > > real 0m0,322s > user 0m0,138s > sys 0m0,022s > > > > > On the other hand, Coccinelle cannot guess what are your coding style preferences. > > It would be nice if the pattern recognition could be improved another bit. > But we tend to concentrate mostly on Linux source code variations so far. > > Regards, > Markus > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [cocci] Reducing parentheses (with SmPL)? 2025-07-22 11:12 ` Julia Lawall @ 2025-07-22 11:26 ` Markus Elfring 0 siblings, 0 replies; 26+ messages in thread From: Markus Elfring @ 2025-07-22 11:26 UTC (permalink / raw) To: Julia Lawall, cocci >> Another SmPL script example: >> @replacement@ >> expression condition, context, x, y; >> identifier action; >> @@ >> -if (condition) >> - { action(context, x); } >> -else >> - { action(context, y); } >> +action(context, (condition) ? (x) : (y)); >> >> >> Questionable test result (by the software combination “Coccinelle 1.3.0” for example): >> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> git checkout next-20250722 && time /usr/bin/spatch …/Projekte/Coccinelle/Probe/use_selected_call_with_ternary_operator-20250722.cocci fs/xfs/scrub/findparent.c >> … >> @@ -229,11 +229,8 @@ xrep_findparent_live_update( >> … >> + xrep_findparent_scan_found(pscan, >> + (p->delta > 0) ? (p->dp->i_ino) : (NULLFSINO)); >> … >> @@ -269,10 +266,8 @@ __xrep_findparent_scan_start( >> … >> + xfs_dir_hook_setup(&pscan->dhook, >> + (custom_fn) ? (custom_fn) : (xrep_findparent_live_update)); >> … > > Why is it a surprise to see the () if you put the ()? Am I forced to specify additional parentheses for the desired source code transformation pattern because I can not know so far if the found expressions would really fit into the recombined expressions? Should pretty-printing approaches take care of corresponding format adjustments? Regards, Markus ^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2025-07-22 11:26 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-19 12:04 [cocci] Reducing parentheses (with SmPL)? Markus Elfring
2025-07-19 19:16 ` Julia Lawall
2025-07-20 7:21 ` Markus Elfring
2025-07-20 14:10 ` Julia Lawall
2025-07-20 18:08 ` Markus Elfring
2025-07-21 5:30 ` Markus Elfring
2025-07-21 5:48 ` Julia Lawall
2025-07-21 6:30 ` Markus Elfring
2025-07-21 6:46 ` Julia Lawall
2025-07-21 6:58 ` Markus Elfring
2025-07-21 7:45 ` Julia Lawall
2025-07-21 7:55 ` Markus Elfring
2025-07-21 7:58 ` Julia Lawall
2025-07-21 8:10 ` Markus Elfring
2025-07-21 8:23 ` Julia Lawall
2025-07-21 8:45 ` Markus Elfring
2025-07-21 9:51 ` Markus Elfring
2025-07-21 11:00 ` Julia Lawall
2025-07-21 11:21 ` Markus Elfring
2025-07-21 11:54 ` Julia Lawall
2025-07-21 12:14 ` Markus Elfring
2025-07-22 6:21 ` Markus Elfring
2025-07-22 7:33 ` Markus Elfring
[not found] ` <479a2492-62de-2b9d-4899-4d4f35f653e9@inria.fr>
2025-07-22 11:10 ` Markus Elfring
2025-07-22 11:12 ` Julia Lawall
2025-07-22 11:26 ` Markus Elfring
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.