On Thu, 27 Mar 2014 09:24:49 +1100, Chris Angelico wrote:

> On Thu, Mar 27, 2014 at 4:32 AM, Rustom Mody <rustompm...@gmail.com>
> wrote:
>> Now actual python
>>
>> def sumjensen(i_get, i_set,lower,upper,exp):
>>     tot = 0
>>     i_set(lower)
>>     while i_get() <= upper:
>>         tot += exp_get()
>>         i_set(i_get() + 1)
>>     return tot
>>
>>
>> i=0
>> a=[3,4,5]
>> i_get = lambda : i
>> def i_set(val):
>>    global i
>>    i = val
>>
>> exp_get = lambda : a[i_get()]
>>
>>
>> call as sumjensen(i_get, i_set, lower, upper, exp_get)
>>
>> [Note that because of lambda's restriction to being only an expression
>> I have to make it a def because of need for  global]
> 
> You prove here that Python has first-class expressions in the same way
> that 80x86 assembly language has garbage collection. Sure, you can
> implement it using the primitives you have, but that's not support.

+1


Any language can work around the lack of a language feature by sufficient 
layers of indirection, but that's not the same as having that language 
feature.

Beyond a certain minimum feature set, all languages are Turing complete, 
and so in one sense are of equivalent power. But they're not all of equal 
expressiveness. Python is awesome, it is very expressive, but there are 
certain things you can't write directly in Python, and have to resort to 
circumlocutions instead.

See also Paul Graham's "Blub language" essay:

http://paulgraham.com/avg.html




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to