为什么要使用多个名称空间? [英] Why multiple namespaces?

查看:48
本文介绍了为什么要使用多个名称空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Common Lisp中为值和函数使用单独的命名空间的设计决策背后的原理是什么?支持和反对的理由是什么?

What is the rationale behind the design decision to have separate namespaces for values and functions in Common Lisp? What are the arguments for and against it?

推荐答案

Common Lisp基本上是原始Lisp 1.5的后代,或者说是其不同方言的统一.最初的Lisp 1.5是当今称为Lisp-2的东西.因为它可以追溯到六十年代,而且您可以将函数传递给其他函数这一事实已经很奇怪了.甚至没有人想到让他们共享相同的名称空间.如今,几乎所有发明的支持高阶函数和匿名函数的语言都选择了单命名空间方法.包括Clojure,在其他方面更接近Common Lisp,而不是Scheme.

Common Lisp is basically a descendant from the original Lisp 1.5, or rather, a unification of its diverging dialects. The original Lisp 1.5 was what is nowadays called a Lisp-2. Because it was back in the sixties and the fact that you could pass functions to other functions was weird enough. No one would even think of letting them share the same namespace. Almost any language invented today with support for higher order functions and anonymous functions chooses the single-namespace approach. Including Clojure, which is otherwise closer to Common Lisp than to Scheme.

与Clojure一样,方案最初并不是Lisp 1.5的方言,出于他们的目的,这是有道理的.

Scheme, like Clojure, wasn't originally a divergent dialect from Lisp 1.5, and for their purposes it makes sense.

当然,在Clojure中,向量,哈希图,集合以及所有可以应用于参数的东西,因此在某种意义上,Clojure中的向量可以看作是一个采用自然数并从中产生值的函数

Of course, in Clojure, vectors, hash maps, sets and all that can also be applied to arguments, so in a sense a vector in Clojure could be seen as a function that takes a natural number and produces a value from that.

这篇关于为什么要使用多个名称空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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