digitalmars.D - Expression transformation by symbol name
- Dominic Jones (17/17) Sep 08 2017 Hello,
- Dominic Jones (3/6) Sep 08 2017 1. "transform(a + a)" returns an object to evaluate "2 * a"
Hello, Is there a way in D of applying a transform function to the following expressions at compile-time such that the first is modified and the second left unchanged? Where 'a' and 'b' are of the same type: 1. "transform(a * a)" returns an object to evaluate "2 * a" 2. "transform(a * b)" returns an object to evaluate "a * b" Such transformations appear to be impossible without some kind of access to the symbol name in order to distinguish the two scenarios. If it is possible, what are the reflection functions one would need to use to implement this? If it is not possible, has there been any interest or attempts to add such reflection functionality to the language to make it possible? Thank you, Dominic Jones
Sep 08 2017
On Friday, 8 September 2017 at 13:15:51 UTC, Dominic Jones wrote:Where 'a' and 'b' are of the same type: 1. "transform(a * a)" returns an object to evaluate "2 * a" 2. "transform(a * b)" returns an object to evaluate "a * b"1. "transform(a + a)" returns an object to evaluate "2 * a" 2. "transform(a + b)" returns an object to evaluate "a + b"
Sep 08 2017