[vector] Non capturing lambda

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Thu Feb 28 01:07:51 UTC 2019


Hi Sandhya,

> The question I have is why is the following lambda considered a 
> capturing lambda?  The “species” is a parameter so cannot be capturing, 
> am I correct? The rest of the lambda is as before.
> 
>                                       (c, idx) -> species.op(n -> c[idx 
> + n])

'species' isn't a lambda parameter. It's a part of context and has to be 
captured, since it is used in the lambda body.

In order to keep lambdas which represents default implementations 
non-capturing, only its arguments and static fields are allowed to be used.

I don't see an easy way to fix that without introducing new 
VectorIntrinsics variants to pass 'species' instance into default 
implementation.

I suggest to move the implementation back to Species and call it from 
XxxVector instead.

Best regards,
Vladimir Ivanov


More information about the panama-dev mailing list