[Oc-pm] Meeting Notes
Ben Tilly
btilly at gmail.com
Fri May 25 10:53:57 PDT 2007
On 5/25/07, Mark D. Nagel <mnagel at willingminds.com> wrote:
> Ben Tilly wrote:
> > You can't really do the Y Combinator in Perl because one of the key
> > points of the combinator is that you should not need any form of
> > assignment, and Perl can't process function arguments without using
> > assignment.
>
> I'm not familiar with all the details on this one, but is the problem
> that when you use function arguments without assignment that they are
> passed by reference? Because I know you can process arguments without
> assignment as long as they are not altered (unless that is the intent)
> and you don't mind line noise :).
Passed by reference is not the problem. Dynamic scoping is.
To make the Y Combinator work you need to use currying, and currying
requires lexically scoped variables. Currying is turning things like
F = function (i, j) {
...
};
F(i,j);
into things like
F = function (i) { return function (j) {
...
}};
F(i)(j);
but that only works if the anonymous function returned by the second
version of F actually has i lexically scoped.
Cheers,
Ben
More information about the Oc-pm
mailing list