digitalmars.D.learn - Nested template arguments
- XavierAP (9/9) Aug 22 2018 Why
- Alex (7/17) Aug 22 2018 Because it could be meant as the argument to some templates to
- XavierAP (5/11) Aug 22 2018 Of course there isn't an associative property... But I was
- Alex (6/19) Aug 22 2018 Ah... ok. Got your idea. No. This isn't possible because some
- Steven Schveighoffer (4/26) Aug 23 2018 Note that Instantiate in std.meta exists to overcome this limitation:
Why foo!bar!x is not understood as foo!(bar!x) but instead gives an error "multiple ! arguments are not allowed"? Precisely because multiple "!" can never belong to the same instantiation, why does the parser not understand without needing brackets that the rightmost template should be nested as the argument for the next one to the left?
Aug 22 2018
On Wednesday, 22 August 2018 at 14:30:39 UTC, XavierAP wrote:Why foo!bar!x is not understood as foo!(bar!x) but instead gives an error "multiple ! arguments are not allowed"? Precisely because multiple "!" can never belong to the same instantiation, why does the parser not understand without needing brackets that the rightmost template should be nested as the argument for the next one to the left?Because it could be meant as the argument to some templates to the left. Like (foo!bar)!x Sure, it would be a coincidence, if both will work. However, templates are not something where you can simply imply the associative property, I think.
Aug 22 2018
On Wednesday, 22 August 2018 at 14:48:57 UTC, Alex wrote:Because it could be meant as the argument to some templates to the left. Like (foo!bar)!x Sure, it would be a coincidence, if both will work. However, templates are not something where you can simply imply the associative property, I think.Of course there isn't an associative property... But I was thinking that without brackets the parser could fall back to whatever default "left to right" precedence, as would happen with operators, which needn't be associative either.
Aug 22 2018
On Wednesday, 22 August 2018 at 15:18:29 UTC, XavierAP wrote:On Wednesday, 22 August 2018 at 14:48:57 UTC, Alex wrote:Ah... ok. Got your idea. No. This isn't possible because some symmetry of the operator is implied. https://wiki.dlang.org/Operator_precedence Chaining is explicitly not allowed, like in comparison operators :)Because it could be meant as the argument to some templates to the left. Like (foo!bar)!x Sure, it would be a coincidence, if both will work. However, templates are not something where you can simply imply the associative property, I think.Of course there isn't an associative property... But I was thinking that without brackets the parser could fall back to whatever default "left to right" precedence, as would happen with operators, which needn't be associative either.
Aug 22 2018
On 8/22/18 11:37 AM, Alex wrote:On Wednesday, 22 August 2018 at 15:18:29 UTC, XavierAP wrote:Note that Instantiate in std.meta exists to overcome this limitation: Instantiate!(foo!bar, x); -SteveOn Wednesday, 22 August 2018 at 14:48:57 UTC, Alex wrote:Ah... ok. Got your idea. No. This isn't possible because some symmetry of the operator is implied. https://wiki.dlang.org/Operator_precedence Chaining is explicitly not allowed, like in comparison operators :)Because it could be meant as the argument to some templates to the left. Like (foo!bar)!x Sure, it would be a coincidence, if both will work. However, templates are not something where you can simply imply the associative property, I think.Of course there isn't an associative property... But I was thinking that without brackets the parser could fall back to whatever default "left to right" precedence, as would happen with operators, which needn't be associative either.
Aug 23 2018