From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-04-03T08:34:16+09:00 Subject: Re: seeking to understand... In article <87wuvp9460.fsf@jenny-gnome.dyndns.org>, Yohanes Santoso wrote: >ptkwt@shell1.aracnet.com (Phil Tomson) writes: > >> In article <87hemtaotb.fsf@jenny-gnome.dyndns.org>, >> Yohanes Santoso wrote: >> >ptkwt@shell1.aracnet.com (Phil Tomson) writes: >> > >> >> Ruby has several important features lacking in Python, such as lexical >> >> closures. And the fact that Python just recently added iterators and >> > >> >What is this "lexical closures" that I've been hearing about? Most >> >probably it is something that I have been taking for granted. >> > >> >YS. >> >> b. Using a Proc (which, remember, is a closure) allows me to do that. > >Thanks Phil for the explanation. Now I know for sure that I've been >taking lexical closure for granted. I've been using Proc in the manner >you described. However, intead of naming what I do as lexical closure, >I named them dynamic action. Now I know its proper name. Priceless. > >In Java, lexical closure is achievable with the use of anonymous class >with some additional work: keeping the values of a and b somewhere >within the anon class. I'm pretty rusty on Java, but I'm not sure that achieves the same thing as a closure. Could you show an example? I guess you're saying that you would have to pass the anon class around and that it would contain your closure function, correct? Phil