为什么smalltalk不是一种功能性编程语言? [英] Why is smalltalk not a functional programming language?

查看:123
本文介绍了为什么smalltalk不是一种功能性编程语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着对函数式编程语言重新兴趣的兴趣,我看到了Smalltalk和FPL之间的一些相似之处,即关闭(Smalltalk中的BlockClosures)。然而,Smalltalk不是FPL?



需要考虑的是什么?

解决方案

面向对象模式编程通过识别问题域实体并将其模型化为对象来创建程序,然后使它们之间协作解决每个问题实例。
使用功能范例进行编程是将问题建模为数学问题,并为每个问题实例创建一个数学函数(通过组合其他函数)来计算问题解决方案。

在我看来,函数式编程语言是一种为使用函数式编程范式解决的问题提供解决方案的语言,该语言可以完全按照它的想法来表达该解决方案。如果您需要转换解决方案的某些部分,以适应语言所能表达的内容,那么它并不完全支持您以前认为解决方案的范例。



Smalltalk在大多数情况下可以表达所有使用面向对象编程范例创建的解决方案,但它不能原始地表达使用函数式编程范例创建的大量解决方案。这就是为什么我不认为它是FPL。
尽管不能够表达FPL可以提供的每个解决方案,但Smalltalk是极其可扩展的,您可以将其扩展为能够表达FPL可以提供的所有解决方案。

With the renewed interest in functional programming languages, I've seen some similitudes between Smalltalk and FPL, namely closures ( BlockClosures in Smalltalk ) Yet, Smalltalk is not a FPL?

What would be needed to consider it as such?

解决方案

Programming with the Object Oriented paradigm is creating a program by identifying and modeling the Problem Domain Entities as objects, and then make them collaborate between themselves to solve each problem instance. Programming with the Functional paradigm is modeling the problem as a mathematical problem, and creating a mathematical function (by composing other functions) that for each problem instance, computes the problem solution.

In my opinion, a functional programming language is a language that given a solution for a problem solved using the functional programming paradigm, the language can express that solution exactly as it was thought. If you need to "transform" some part of your solution so it fits in what the language can express, then it doesn't fully support the paradigm you used to think the solution.

Smalltalk can express in most cases all the solutions created using the Object Oriented Programming paradigm, but it cannot expresss primitively a lot of solutions created using the Functional Programming paradigm. That's why I don't consider it a FPL. Despite not primitively be able to express every solution that a FPL can, Smalltalk is extremelly extensible, and you can extend it to be able to express all the solutions a FPL can.

这篇关于为什么smalltalk不是一种功能性编程语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆