A inner pure function problem

bearophile bearophileHUGS at lycos.com
Mon Feb 20 14:55:50 PST 2012


Timon Gehr:

> T outer(T)(T function(in T) pure foo) pure {
>      immutable fooTick = foo;
>      pure int inner() {
>          return fooTick(5); // line 3
>      }
>      return inner();	
> }
> int sqr(in int x) pure {
>      return x * x;
> }
> void main() {
>      assert(outer(&sqr) == 25); // line 14
> }

Nice.


> The fact that qualifying the parameter with immutable directly causes a 
> matching failure in IFTI appears to be a bug.

http://d.puremagic.com/issues/show_bug.cgi?id=7554

Thank you, bye,
bearophile


More information about the Digitalmars-d-learn mailing list