From: Christoph (news_chr) Date: 2003-10-05T07:56:33+09:00 Subject: Re: Python syntax in Lisp and Scheme "Alex Martelli" wrote: .... > def outer(a) proc do |b| a+=b end end > > x = outer(23) > puts x.call(100) # emits 123 > puts x.call(100) # emits 223 > > [i.e., I can't think of any way you could just use x(100) > at the end of such a snippet in Ruby -- perhaps somebody > more expert of Ruby than I am can confirm or correct...?] Guy is probably thinking about something like this --- def outer(sym,a) Object.instance_eval { private # define a private method define_method(sym) {|b| a+=b } } end outer(:x,24) p x(100) # 124 p x(100) # 224 --- but there is no way to write a ``method returning method ::outer in Ruby that could be used in the form ---- x = outer(24) x(100) ---- On the other hand, using []-calling convention and your original definition, you get - at least visually - fairly close. --- def outer(a) proc do |b| a+=b end end x = outer(23) puts x[100] # emits 123 puts x[100] # emits 223 --- /Christoph