什么是“表达问题"? [英] What is the 'expression problem'?

查看:22
本文介绍了什么是“表达问题"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这是什么有一个粗略的想法,但如果有人对他们认为简洁直观的表达问题"有一个解释,我很乐意听到.

I have a rough idea about what this is but if someone has an explanation of the 'expression problem' that they think is succinct and intuitive I would love to hear it.

推荐答案

观看 本讲座.

这个想法是你的程序是数据类型和对它的操作的组合.该问题要求实现允许添加类型的新案例和新操作,而无需重新编译旧模块并保持静态类型安全(无强制转换或运行时类型检查).

The idea is that your program is a combination of a datatype and operations over it. The problem asks for an implementation that allows to add new cases of the type and new operations without the need for recompilation of the old modules and keeping static type safety(no casts or runtime type checks).

有趣的是,在函数式编程语言中,添加新操作很容易,但向数据类型添加 case 却很难.在面向对象语言中,情况正好相反.这是两种编程范式在概念上的重大差异之一.

It's interesting to notice that in functional programming languages it's easy to add new operations, but hard to add cases to the datatype. While in an OO language it's the other way round. This is one of the big conceptual differences between the two programming paradigms.

这篇关于什么是“表达问题"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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