[plt-scheme] why local? (just curious)

From: kumar (kumar_lista at mac.com)
Date: Thu Jan 15 21:31:34 EST 2009

Sorry I missed that one. Its clearer now.

I came across local first in the web app tutorial
and I both liked it and at the same time felt it was redundant.

I just looked into the code for local (local.ss). It looks
like the difference from begin lies in the line -
	...  [expand-context (generate-expand-context)] ...

It looks like the whole things is expanded in a nested
context which begin doesn't. Am I right?


On 16 Jan 2009, at 9:58 AM, Shriram Krishnamurthi wrote:

> If you mean a different semantics for this than Scheme's internal
> define, then you're going to create confusion.
> If you mean the same semantics as Scheme's internal define, kindly
> refer to the comp.lang.scheme thread I pointed you to.
> Shriram
> On Thu, Jan 15, 2009 at 8:45 PM,  <kumar_lista at mac.com> wrote:
>>> Ah!  The primary reason we used local for those examples was to  
>>> avoid
>>> the use of lambda for the the internal function definitions.  We
>>> wanted to make the tutorial easy for newcomers to read.
>> Why not just permit (define ...) expressions anywhere with
>> mutually recursive bindings possible in the same scope,
>> so you don't have to use local in the first place?
>> Rewriting Sigrid's example -
>> (define (test n)
>>        (define start-value n)
>>        (define zero (- start-value start-value)
>>        (define (even? n) (if (= n zero) #t (odd? (- n 1))))
>>        (define (odd? n) (if (= n zero) #f (even? (- n 1))))
>>        (odd? n))
>> -Kumar
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.