有没有纯功能的方案或Lisps? [英] Are there any purely functional Schemes or Lisps?

查看:160
本文介绍了有没有纯功能的方案或Lisps?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我玩过几种函数式编程语言,并且非常喜欢Lisp(特别是Scheme)使用的s-expr语法。



我也看到了以纯功能语言工作的优势。因此:

是否有任何纯粹功能性的Schemes(或一般的Lisps)?

可能不是,至少不是玩具/概念验证以外的任何东西。请注意,即使Haskell也不是100%纯功能的 - 它具有秘密逃生舱口,并且任何 IO 都是只有在词汇的一些曲折,手摇的感觉中才是纯粹的。



因此,那就是说,你真的需要一种纯粹的功能性语言吗?您可以用几乎任何语言编写纯粹功能的代码,但会带来不同程度的不便和低效。当然,修改会让事情变得很纯粹,所以也许你真正想要的是一种鼓励不变性的语言?在这种情况下,您可能会觉得值得看看 Clojure 的理念。而且它是一个Lisp,可以启动!



最后要注意的是,要明白Haskell的大部分语法都是厚厚的糖。底层语言不仅仅是一种类型化的lambda演算,并且没有什么能阻止你以这种方式编写所有代码。不过,您可能会从其他Haskell程序员那里看起来很有趣。还有 Liskell ,但我不确定它现在处于什么状态。



在最后一个实际的注释中:如果你想真正编写你打算使用的代码,不要只是为了好玩而修改东西,你会 想要一个聪明的编译器,知道如何使用纯代码/不可变数据结构。


I've played around with a few functional programming languages and really enjoy the s-expr syntax used by Lisps (Scheme in particular).

I also see the advantages of working in a purely functional language. Therefore:

Are there any purely functional Schemes (or Lisps in general)?

解决方案

Probably not, at least not as anything other than toys/proofs of concept. Note that even Haskell isn't 100% purely functional--it has secret escape hatches, and anything in IO is only "pure" in some torturous, hand-waving sense of the word.

So, that said, do you really need a purely functional language? You can write purely functional code in almost any language, with varying degrees of inconvenience and inefficiency.

Of course, languages that assume universal state-modification make it painful to keep things pure, so perhaps what you really want is a language that encourages immutability? In that case, you might find it worthwhile to take a look at Clojure's philosophy. And it's a Lisp, to boot!

As a final note, do realize that most of Haskell's "syntax" is thick layers of sugar. The underlying language is not much more than a typed lambda calculus, and nothing stops you from writing all your code that way. You may get funny looks from other Haskell programmers, though. There's also Liskell but I'm not sure what state it's in these days.

On a final, practical note: If you want to actually write code you intend to use, not just tinker with stuff for fun, you'll really want a clever compiler that knows how to work with pure code/immutable data structures.

这篇关于有没有纯功能的方案或Lisps?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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