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

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

问题描述

在 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.因为那是在 60 年代,你可以将函数传递给其他函数的事实已经够奇怪了.甚至没有人会想到让它们共享同一个命名空间.今天发明的几乎所有支持高阶函数和匿名函数的语言都选择单一命名空间方法.包括 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.

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天全站免登陆