For faster navigation, this Iframe is preloading the Wikiwand page for Hy语言.

Hy语言

Hy
编程范型多范型: 过程式, 函数式, 面向对象, 元编程, 反射式, 泛型
语言家族Lisp
設計者Paul Tagliamonte
實作者核心团队
发行时间2013年,​11年前​(2013
当前版本
  • 0.29.0 (2024年5月20日;穩定版本)[1]
編輯維基數據鏈接
作用域词法
實作語言Python
系统平台IA-32, x86-64
操作系统跨平台
許可證MIT
文件扩展名.hy
網站hylang.org
啟發語言
Kawa英语Kawa (Scheme implementation), Clojure, Common Lisp

HyLisp编程语言的一种方言。它设计用于同Python语言进行交互,方式是把表达式翻译成Python的抽象语法树(AST)[2][3]。Paul Tagliamonte在2013年于Python会议(PyCon)介绍了Hy[4]

类似于Kawa英语Kawa (Scheme implementation)Clojures-表达式映射到Java虚拟机(JVM)之上[5],Hy必定作为Python抽象语法树的透明Lisp前端来运行[6]。Lisp允许像数据那样在代码上进行操作(元编程)。因此,Hy可以用来书写领域特定语言[7]。Hy还允许导入Python包括标准库,并与Hy代码一起被访问,方式是通过一个编译步骤[note 1],将二者的数据结构翻译成Python的AST[note 2][8][9][10]

例子代码

[编辑]

来自语言文档的例子[11]

=> (print "Hy!")
Hy!
=> (defn salutationsnm [name] (print (+ "Hy " name "!")))
=> (salutationsnm "YourName")
Hy YourName!

参见

[编辑]
Hy标志和吉祥物墨鱼Cuddles

注释

[编辑]
  1. ^ “编译”这个术语可以应用于将Hy代码表达为Python的AST或将这个AST转换成字节码,后者依赖于所使用的特定Python解释器而非Hy。
  2. ^ Hy在Python 2.7、3.4到3.6和PyPy上测试过。

引用

[编辑]
  1. ^ 1.0 1.1 Release 0.29.0. 2024年5月20日 [2024年5月23日]. 
  2. ^ Jaworski, Michał; Ziadé, Tarek. Expert Python programming Third. Birmingham, U.K.: Packt Publishing. 2019: 173. ISBN 978-1-78980-677-9. OCLC 1125343555. 
  3. ^ Danjou, Julien. Serious Python: black-belt advice on deployment, scalability, testing, and more. San Francisco, CA: No Starch Press. 2018: 145–149. ISBN 9781593278793. OCLC 1057729260. 
  4. ^ Tagliamonte, Paul. PyCon lightning talk (演讲). Python Conference (PyCon). Santa Clara. 2 April 2013 [2 September 2014]. (原始内容存档于2020-10-19). 
  5. ^ Turto, Tuukka. Programming Can Be Fun with Hy. Open Source For You. 14 February 2014 [2 September 2014]. (原始内容存档于2020-08-03). 
  6. ^ Edge, Jake. Getting Hy on Python. LWN.net. 30 April 2014 [2 September 2014]. (原始内容存档于2020-10-12). 
  7. ^ Tagliamonte, Paul. Getting Hy on Python: How to implement a Lisp front-end to Python (演讲). PyCon. Montreal. 11 April 2014 [2 September 2014]. (原始内容存档于2020-10-20). 
  8. ^ Hy Documentation. hylang.org. [3 September 2014]. (原始内容存档于2020-11-25). 
  9. ^ Danjou, Julien. The AST. The Hacker's Guide to Python. 26 March 2014: 165–172. 
  10. ^ Kitchin, John. More on Hy and why I think it is a big deal. The Kitchin Research Group. Carnegie Mellon University. 31 March 2016 [19 September 2018]. (原始内容存档于2020-02-17). 
  11. ^ Quickstart. Hylang.org. 15 May 2018 [19 September 2018]. (原始内容存档于2019-08-14). 
  12. ^ Hissp. [2020-10-09]. (原始内容存档于2020-09-20). 
  13. ^ SchemePy. [2020-10-10]. (原始内容存档于2018-07-09). 

外部链接

[编辑]
{{bottomLinkPreText}} {{bottomLinkText}}
Hy语言
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?