官术网_书友最值得收藏!

Metaprogramming in Julia

Everything in Julia is an expression that returns a value when executed. Every piece of the program code is internally represented as an ordinary Julia data structure, also called an expression. In this chapter, we will see how, by working on expressions, a Julia program can transform and even generate new code. This is a very powerful characteristic, also called homoiconicity. It inherits this property from Lisp, where code and data are just lists, and where it is commonly referred to with the phrase: Code is data and data is code.

In homoiconic languages, code can be expressed in terms of the language syntax. This is the case for the Lisp-like family of languages: Lisp, Scheme and, more recently, Clojure, which use s-expressions. Julia is homoiconic, as are others such as Prolog, IO, Rebol, and Red. As such, these are able to generate code during runtime, which can be subsequently executed.

We will explore this metaprogramming power by covering the following topics:

  • Expressions and symbols
  • Evaluation and interpolation
  • Defining macros
  • Built-in macros
  • Reflection capabilities
主站蜘蛛池模板: 宜川县| 广平县| 瑞昌市| 陕西省| 门源| 缙云县| 德庆县| 炎陵县| 治县。| 凌云县| 凌云县| 朝阳县| 裕民县| 五家渠市| 绥德县| 银川市| 晋州市| 班玛县| 威海市| 环江| 定日县| 许昌县| 长宁县| 绥中县| 十堰市| 扶余县| 镇远县| 公主岭市| 临洮县| 广德县| 巍山| 双鸭山市| 那曲县| 定州市| 诸城市| 蓬安县| 伽师县| 平陆县| 尼勒克县| 云浮市| 高陵县|