NotNull pointers

kennytm kennytm at gmail.com
Wed Aug 31 20:02:28 PDT 2011


Timon Gehr <timon.gehr at gmx.ch> wrote:
> On 09/01/2011 01:03 AM, Timon Gehr wrote:
>> On 09/01/2011 12:26 AM, Simen Kjaeraas wrote:
>>> On Wed, 31 Aug 2011 23:54:04 +0200, Timon Gehr <timon.gehr at gmx.ch> wrote:
>>> 
>>>>> [2 * x ; x <- iota(10), log(x), x*x > 4]
>>>>> 
>>>>> or, in a library:
>>>>> 
>>>>> compr!q {2 * x ; x <- iota(10), log(x), x*x > 4};
>>>>> 
>>>>> 
>>>> 
>>>> compr!q{2 * x ; x <- iota(10), log(x), x*x > 4};
>>> 
>>> The library solution has problems with scope variables.
>> 
>> I know, that is why I have not implemented this yet. Basically it should
>> be possible to implicitly pass a whole scope to a template, or at least,
>> to have local templates.
>> 
>>> Example:
>>> 
>>> auto foo(Range)(int n, Range r) {
>>> return compr!q{x * n; x <- arr, log(x), x*x > 4};
>>> }
>> 
>> Workaround:
>> auto foo(Range)(int n, Range r) {
>> mixin Compr!q{x * n ; x <- arr, log(x), x*x > 4};
>> return compr;
>> }
>> 
>> 
> 
> but
> 
> auto foo(Range)(int n, Range r) {
>     return mixin(compr!q{x * n ; x <- arr, log(x), x*x > 4});
> }
> 
> is clearly better.

Hey guys, the expression 'x <- arr' always means "is x less than negation
of arr?" in D. Please choose another symbol.


More information about the Digitalmars-d mailing list