Английская Википедия:Hy

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

Шаблон:Short description Шаблон:About Шаблон:Infobox programming language

Hy is a dialect of the Lisp programming language designed to interact with Python by translating s-expressions into Python's abstract syntax tree (AST).[1][2] Hy was introduced at Python Conference (PyCon) 2013 by Paul Tagliamonte.[3] Lisp allows operating on code as data (metaprogramming), thus Hy can be used to write domain-specific languages.[4]

Similar to Kawa's and Clojure's mappings onto the Java virtual machine (JVM),[5][6] Hy is meant to operate as a transparent Lisp front-end for Python.[7] It allows Python libraries, including the standard library, to be imported and accessed alongside Hy code with a compiling[note 1] step where both languages are converted into Python's AST.[note 2][8][9][10]

Example code

From the language documentation:[11]

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

See also

Notes

  1. The term "compiled" 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.

References

Шаблон:Reflist

External links

Шаблон:Lisp Шаблон:Lisp programming language