什么是“reify”?和“具体化”在(功能?)编程的背景下意味着什么? [英] What do "reify" and "reification" mean in the context of (functional?) programming?

查看:122
本文介绍了什么是“reify”?和“具体化”在(功能?)编程的背景下意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在有关haskell和函数式编程的博客(特别是 sigfpe的博客)中阅读了这个术语,但是我对于它的含义没有任何线索。我大部分时间都不知道,但是我可能会理解这些文本,如果我知道的话会更好。谷歌没有帮助我。我迷失在技术方面。

这个世界的非技术性含义(转向抽象的具体)并不能帮助我理解它在代码中表达某些东西的实际意义。 p>

我对计算机科学概念比较慢,所以使用代码的实际例子会很好。 :P

解决方案

所以我读到了这一点,它几乎意味着:抽象概念并使其具体。或者,有一个代理抽象概念。例如,在Lisp中,当你使用lambda表达式时,过程抽象和应用程序的概念就被体现出来了。

本身是一个宽泛的概念,不仅适用于函数式编程 - 语言。



例如,在Java中,有些类型在运行时可用。这些是可确定的类型。意思是,在运行时存在该类型的抽象概念的具体表示。相反,有不可兑换的类型。在Java中使用泛型时尤其明显。在Java中,泛型受到类型擦除的限制,因此泛型类型信息在运行时不可用(除非参数化类型使用无限通配符)。另一个例子是何时你尝试建模一个概念。例如,假设您有一个 Group 类和一个 User 类。现在有一些抽象概念描述了两者之间的关系。例如, User Group 的成员的抽象概念。为了使这个关系具体化,你需要编写一个名为 isMemberOf 的方法,该方法说明 User 是否是。所以你在这里完成的是你有通用(真正的/显式的/具体的)抽象概念的组员资格。



另一个很好的例子是在对象之间有父子关系的数据库。您可以在树的抽象概念中描述这种关系。现在假设你有一个函数/方法从数据库获取这些数据并构造一个 Tree 对象。你现在所做的是将父元素树状关系的抽象概念转化为实际 树 object。

通常回到函数式语言,也许最好的例证就是创建Lisp编程语言本身。 Lisp是一个完全抽象的理论构造(基本上只是计算机语言的数学符号)。直到Lisp的 eval 函数实际上由Steve Russel在IBM 704上实现为止:

根据Paul Graham在Hackers&画家,页。 185,麦卡锡说:史蒂夫罗素说,看,为什么我不编程这个评估...,我对他说,你好,理论与实践混淆,这个评估是为了阅读,而不是但他继续做下去,也就是说,他将我的论文中的eval编译成IBM 704机器码,修正了错误,然后将其作为Lisp解释器进行了广告宣传,当然,Lisp曾经基本上就是今天的形式......



因此,Lisp从一个抽象的概念被强化为一个实际的编程语言。  


I read this term a lot in blogs about haskell and functional programming (specially in sigfpe's blog) but I don't have a clue about what it means. I get away with not knowing it most of the times, but I probably would have understood the texts a lot better if I knew. Google didn't help me. I get lost in the technical stuff.

Also the non-technical meaning of the world ("turning the abstract concrete") doesn't help me understand what it practically means to reify something in code.

I'm kinda slow with computer science concepts, so practical examples with code would be nice. :P

解决方案

So I read up on this, and it is pretty much what it means: taking an abstract concept and making it concrete. Or, there is a proxy that represents the abstract concept. For example, in Lisp, the concept of procedure abstraction and application is reified when you use lambdas.

Reification by itself is a broad concept and not just applicable to functional programming-languages.

In Java for example, there are types that are available at runtime. These are reifiable types. Meaning, there exists a concrete representation of the abstract concept of the type, during runtime. In contrast, there are non-reifiable types. This is especially evident during the use of generics in Java. In Java, generics are subject to type erasure, and so generic type-information is not available during runtime (unless the parameterized type uses unbounded wildcards).

Another example is when you try to model a concept. For example, assume that you have a Group class and a User class. Now there are certain abstract concepts that describe the relationship between the two. For example, the abstract concept of a User being the member of a Group. To make this relationship concrete, you would write a method called isMemberOf that says whether a User is a member of a Group. So what you've done here is that you have reified (made real/explicit/concrete) the abstract concept of group membership.

Another good example is a database where you have parent-child relationships between objects. You can describe this relationship in the abstract concept of a tree. Now suppose you have a function/method that takes this data from the database and constructs an actual Tree object. What you've now done is reified the abstract concept of the parent-child tree-like relationship into an actual Tree object.

Coming back to functional languages in general, perhaps the best example of reification is the creation of the Lisp programming language itself. Lisp was a completely abstract and theoretical construct (basically just a mathematical notation for computer languages). It remained that way until Lisp's eval function was actually implemented by Steve Russel on an IBM 704:

According to what reported by Paul Graham in Hackers & Painters, p. 185, McCarthy said: "Steve Russell said, look, why don't I program this eval..., and I said to him, ho, ho, you're confusing theory with practice, this eval is intended for reading, not for computing. But he went ahead and did it. That is, he compiled the eval in my paper into IBM 704 machine code, fixing bug , and then advertised this as a Lisp interpreter, which it certainly was. So at that point Lisp had essentially the form that it has today..."

So Lisp was reified from an abstract concept, into an actual programming language.  

这篇关于什么是“reify”?和“具体化”在(功能?)编程的背景下意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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