トップQs
タイムライン
チャット
視点

Hy

ウィキペディアから

Hy
Remove ads

Hy(またはHylang)は、式をPythonAST(抽象構文木)へ変換することで、PythonとLisp間でのやり取りができるように設計されたプログラミング言語Lisp方言のひとつである。HyはPython Conference(PyCon)2013でPaul Tagliamonteが発表した[2]

概要 パラダイム, 登場時期 ...

KawaClojureにおいて、S式Java仮想マシン(JVM)の抽象構文木にマッピングされるのと同様に[3]、Hyは、Pythonの抽象構文に対する透過的なLispフロントエンドとして使用することが想定されている[4]。Lispではコード自体をデータとして操作することが可能である(メタプログラミング)ため、Hyをドメイン固有言語(DSL)として使用することができる[5]。Hyのコードは、コンパイル[note 1]時に両言語のコードをPythonのASTにステップ変換するため、標準ライブラリを含むPythonのライブラリにインポートしたり、ライブラリからHyのコードにアクセスしたりすることが可能である[note 2][6][7][8]

Remove ads

コード例

以下はHy言語のドキュメントからの引用である[9]

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

関連項目

出典

  1. "Compiled" is a term which may apply to expressing Hy code in Python's AST or converting that AST into bytecode, the latter being dependent on the specific Python interpreter used and not Hy.
  2. Hy is tested on Python 2.7, 3.4 through 3.6, and PyPy.

参考文献

外部リンク

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads