A feture adjustment request and a syntax blasphemy
David Medlock
noone at nowhere.com
Sat Oct 28 18:38:52 PDT 2006
BCS wrote:
> This is allowed:
>
> void foo(int[] ar){}
> ...
> static int[] i = [1,2,3];
> i.foo();
>
> And this is allowed:
>
> struct I
> {
> int[] v;
> void foo(){}
> }
> ...
> I i;
> auto dg = &i.foo;
>
> So why no this?
>
> void foo(int[] ar){}
> ...
> static int[] i = [1,2,3];
> auto dg = &i.foo;
>
>
If I am not mistaken but this is a closure.
In javascript the above is:
var i = [ 1,2,3,4];
var dg = function() { return foo(i); }
If you have a function
f( a, b )
then you wish to call it with only a single parameter
g = f(x)
this will yield
a function g which has the following behavior:
g( y ) = f( x, y )
This is currying, or partial evaluation.
A good paper on this is:
http://www.dina.kvl.dk/~sestoft/pebook/
Very good paper.
-DavidM
More information about the Digitalmars-d-learn
mailing list