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

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
主站蜘蛛池模板: 哈密市| 桂林市| 内乡县| 怀集县| 大理市| 宣威市| 万荣县| 永济市| 宝鸡市| 大埔县| 松滋市| 兰西县| 昆明市| 海门市| 峨边| 昌吉市| 三亚市| 水富县| 明水县| 大竹县| 永济市| 台东市| 蒙阴县| 静海县| 洛南县| 张家港市| 盈江县| 新竹市| 湖口县| 益阳市| 若尔盖县| 西林县| 民和| 安丘市| 霍州市| 武威市| 金溪县| 泗阳县| 阜阳市| 扶绥县| 章丘市|