From yikelu.home at gmail.com  Wed May 30 20:43:41 2012
From: yikelu.home at gmail.com (Yike Lu)
Date: Wed, 30 May 2012 14:43:41 -0400
Subject: [Rd] Curry: proposed new functional programming, er, function.
In-Reply-To: <CABdHhvHzLj_BAjx+pMeP2YT9QQEV=_wVw8c3NqTBfp2XHLt6Eg@mail.gmail.com>
References: <7098abec0711011200va3851o811f60bb100616ce@mail.gmail.com>
	<BANLkTi=jud5hhis5y-veQKZHzSYYoPqnBw@mail.gmail.com>
	<79F23BA7BB084E4FA01A8B93904CD02CF669FAA4C9@WIGGUMVS.win.ad.jhu.edu>
	<4DC16917.5090206@gmail.com>
	<BANLkTikuy3OP8j5aymKuE_zmHtYLCkBZWg@mail.gmail.com>
	<79F23BA7BB084E4FA01A8B93904CD02CF669FAA4D7@WIGGUMVS.win.ad.jhu.edu>
	<BANLkTikvfsyZaW4wDB8sA-Z7G-rMQ+11Tg@mail.gmail.com>
	<BANLkTikGcviLYfFska4vkf5GpuCpmKTdJw@mail.gmail.com>
	<BANLkTik-1s+Af541ZkM+mDVkjRx94WM_4w@mail.gmail.com>
	<1337802805327-4631127.post@n4.nabble.com>
	<CABdHhvF1zJpDYXo3i7N30r5OQ0_Qj99_Rzpg-2oNRkdDNJFDfw@mail.gmail.com>
	<4FBFE810.5070405@gmail.com>
	<CABdHhvHzLj_BAjx+pMeP2YT9QQEV=_wVw8c3NqTBfp2XHLt6Eg@mail.gmail.com>
Message-ID: <4FC66A5D.7030403@gmail.com>

I just realized that even in the non-nested case, calling from top level 
"broke" some of my code "inexplicably", since the globally stored 
function call gets overridden if you call Curry again. So old Curried 
functions break.

Glad to have this fix.

On 5/25/2012 5:23 PM, Hadley Wickham wrote:
>
>> call("function", [...]) calls the "function" function, which itself takes 2
>> arguments: the list of formal args and the function body.
>> eval of this call returns the newly constructed function, which you assign
>> to f. Then you assign the parent.frame() as the environment of f, except
>> with the symbol FUN assigned as the original argument FUN.
>>
>> However, upon looking at the debugger, I find that env$FUN<-FUN assigns FUN
>> in Global Scope if Curry is called from the top level.
>> A nested Curry call then creates FUN=function(...) FUN([...]), a recursive
>> infinite loop.
> Yes, that was a really bad idea - not sure why I didn't see the
> problems when I first wrote it.



[Rd] Curry: proposed new functional programming, er, function.
Yike Lu