将 CL 和Scheme 牢记在心
根据我的心情,我似乎在想要 Lisp-1 和 Lisp-2 之间摇摆不定。 不幸的是,除了明显的名称空间差异之外,这还留下了您遇到的各种有趣的函数名称/等问题。 举个例子,今晚我试图编写一些代码(map #'function listvar),当然,这在 CL 中根本不起作用。 我花了一点时间才想起我想要的是地图车,而不是地图。 当然,当 slime/emacs 显示 map 被定义为某种东西时,它没有帮助,尽管显然根本不是相同的功能。
那么,关于如何最大限度地减少选择其中之一并坚持下去的问题的建议呢?
Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tried to do (map #'function listvar) which, of course, doesn't work in CL, at all. Took me a bit to remember I wanted mapcar, not map. Of course it doesn't help when slime/emacs shows map IS defined as something, though obviously not the same function at all.
So, pointers on how to minimize this short of picking one or the other and sticking with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
让两种语言保持一致的最简单方法是用 Common Lisp 进行思考和编写代码。 Common Lisp 代码可以相对容易地转换为Scheme 代码; 然而,从Scheme 转向Common Lisp 可能会引起一些头痛。 我记得有一次我在Scheme 中使用letrec 来存储变量和函数,并且必须将其分成分别用于变量和函数命名空间的单独的CL 函数。
实际上,尽管我没有编写 CL 代码的习惯,但这使得我不得不编写 CL 代码的时候变得更加痛苦。
The easiest way to keep both languages straight is to do your thinking and code writing in Common Lisp. Common Lisp code can be converted into Scheme code with relative ease; however, going from Scheme to Common Lisp can cause a few headaches. I remember once where I was using a letrec in Scheme to store both variables and functions and had to split it up into the separate CL functions for the variable and function namespaces respectively.
In all practicality though I don't make a habit of writing CL code, which makes the times that I do have to all the more painful.
我肯定知道存在语法差异,尽管我肯定还不够流利,无法自动使用它们,这使得代码目前看起来更加相似;-)。
我有一种感觉,你的答案会是这样,但总能希望有捷径<_<。
I'm definitely aware that there are syntactic differences, though I'm certainly not fluent enough yet to automatically use them, making the code look much more similar currently ;-).
And I had a feeling your answer would be the case, but can always hope for a shortcut <_<.
好吧,我认为一旦你在两种语言上获得了足够的经验,这就不再是问题(只是使用类似的自然语言,例如意大利语和西班牙语)。 如果你通常使用一种语言编程,只是偶尔切换到另一种语言,那么不幸的是,你注定要在Scheme中编写Common Lisp,反之亦然;)
有帮助的一件事是为两种语言提供一个独特的视觉环境,在一些其他颜色等。那么至少你将永远知道你是处于 Common Lisp 还是Scheme 模式。
Well, I think that as soon you get enough experience in both languages this becomes a non-issue (just with similar natural languages, like Italian and Spanish). If you usually program in one language and switch to the other only occasionally, then unfortunately you are doomed to write Common Lisp in Scheme or vice versa ;)
One thing that helps is to have a distinct visual environment for both languages, using syntax highlighting in some other colors etc. Then at least you will always know whether you are in Common Lisp or Scheme mode.
Map 比 mapcar 更通用,例如您可以执行以下操作而不是使用mapcar:
我如何在脑海中将scheme和CL分开? 我想当你足够了解两种语言时,你只知道什么在一种语言中有效,而不知道在另一种语言中有效。 尽管语法相似,但它们在风格上是完全不同的语言。
Map is more general than mapcar, for example you could do the following rather than using mapcar:
How do I keep scheme and CL separate in my head? I guess when you know both languages well enough you just know what works in one and not the other. Despite the syntactic similarities they are quite different languages in terms of style.