alexey_rom: (Default)
[personal profile] alexey_rom
Цитата из Masterminds of Programming:
Python probably has the reputation of supporting functional programming based on the inclusion of lambda, map, filter and reduce in the language, but in my eyes these are just syntactic sugar, and not the fundamental building blocks that they are in functional languages. The more fundamental property that Python shares with Lisp (not a functional language either!) is that functions are first-class objects, and can be passed around like any other object. This, combined with nested scopes and a generally Lisp-like approach to function state, makes it possible to easily implement concepts that superficially resemble concepts from functional languages, like currying, map, and reduce. The primitive operators that are necessary to implement those concepts are built into Python, where in functional languages, those concepts are the primitive operations. You can write reduce() in a few lines of Python. Not so in a functional language.

Перевод:
Считается, что Python поддерживает функциональное программирование, скорее всего из-за включения lambda, map, filter и reduce в язык. Но с моей точки зрения это просто синтаксический сахар, а не основные строительные блоки, которыми они являются в функциональных языках. Куда более фундаментальным свойством, общим для Python и Lisp (который тоже не функциональный язык!), является то, что функции — объекты первого класса, и могут передаваться так же, как и любой другой объект. Это, в сочетании с вложенными областями видимости и в общем близким к Lisp'у подходом к состоянию функций, позволяет легко реализовать возможности, поверхностно напоминающие о таких возможностях функциональных языков, как карринг, map, и reduce. В Python встроены примитивные конструкции, необходимые для реализации этих понятий; а вот в функциональных языках они сами и являются примитивными конструкциями. В Python достаточно нескольких строк, чтобы написать reduce(). В функциональных языках это не так.
This account has disabled anonymous posting.
(will be screened)
(will be screened)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

alexey_rom: (Default)
alexey_rom

April 2012

S M T W T F S
1 234567
89 1011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 27th, 2025 08:33 am
Powered by Dreamwidth Studios