Re: With statement extension

2016-04-29 Thread deed via Digitalmars-d
... On Wednesday, 27 April 2016 at 18:34:18 UTC, Artur Skawina wrote: ... ref M() { return matrix.rawArr; } ref Ex1() { return e1.someProperties.someModulusX; } ... If the generated code is equal, without relying on too much optimization, I agree this is close enough, although

Re: With statement extension

2016-04-28 Thread Meta via Digitalmars-d
On Thursday, 28 April 2016 at 11:39:22 UTC, Seb wrote: If it's just about syntax sugar, I definitely would prefer to be able to use alias over ref, e.g. alias v = el.someProperties.aRatio; The main issue with this currently is that you can only alias symbols, but el.someProperties.aRatio is

Re: With statement extension

2016-04-28 Thread Seb via Digitalmars-d
On Thursday, 28 April 2016 at 11:10:21 UTC, Artur Skawina wrote: On 04/28/16 10:28, Adrian Matoga via Digitalmars-d wrote: On Wednesday, 27 April 2016 at 18:34:18 UTC, Artur Skawina wrote: [...] ref Ex1() { return e1.someProperties.someModulusX; } Unless any of the properties is an en

Re: With statement extension

2016-04-28 Thread Artur Skawina via Digitalmars-d
On 04/28/16 10:28, Adrian Matoga via Digitalmars-d wrote: > On Wednesday, 27 April 2016 at 18:34:18 UTC, Artur Skawina wrote: >> [...] >> >>ref Ex1() { return e1.someProperties.someModulusX; } > > Unless any of the properties is an enum or, well, a @property, and I'd expect > both in such

Re: With statement extension

2016-04-28 Thread Adrian Matoga via Digitalmars-d
On Wednesday, 27 April 2016 at 18:34:18 UTC, Artur Skawina wrote: [...] void foo (Matrix matrix, SameType e1, SameType e2) { ref M() { return matrix.rawArr; } ref Ex1() { return e1.someProperties.someModulusX; } ref Ey1() { return e1.someProperties.someModulusY; }

Re: With statement extension

2016-04-27 Thread Artur Skawina via Digitalmars-d
On 04/27/16 15:55, deed via Digitalmars-d wrote: > > A stronger example would be a scope with two similar types, i.e.: > > void foo (Matrix matrix, SameType e1, SameType e2) > { > with ( > M: matrix.rawArr; > Ex1 : e1.someProperties.someModulusX, > Ey1 : e1.someProperties.so

Re: With statement extension

2016-04-27 Thread deed via Digitalmars-d
On Tuesday, 26 April 2016 at 12:53:49 UTC, deed wrote: For example: A stronger example would be a scope with two similar types, i.e.: void foo (Matrix matrix, SameType e1, SameType e2) { with ( M: matrix.rawArr; Ex1 : e1.someProperties.someModulusX, Ey1 : e1.somePropertie

Re: With statement extension

2016-04-27 Thread Marc Schütz via Digitalmars-d
On Tuesday, 26 April 2016 at 12:53:49 UTC, deed wrote: Would it be possible to extend current with statement's expressiveness by two lowerings: 1) Alias expression/symbol and replace in macro fashion: with (a : exprA) { /* use a. will be replaced by exprA by compiler. */ } 2) Accept a list

With statement extension

2016-04-26 Thread deed via Digitalmars-d
Would it be possible to extend current with statement's expressiveness by two lowerings: 1) Alias expression/symbol and replace in macro fashion: with (a : exprA) { /* use a. will be replaced by exprA by compiler. */ } 2) Accept a list of arguments: with (a, b : expr , ...) {} gets lowered