位置: IT常识 - 正文

Homoiconicity

编辑:rootadmin
Homoiconicity - Wikipedia, the free encyclopediaHomoiconicity From Wikipedia, the free encyclopedia HomoiconicityFrom Wikipedia, the free encyclopediaJump to:navigation, searchThis article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (April 2012)

推荐整理分享Homoiconicity,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

In computer programming, homoiconicity is a property of some programming languages, in which the primary representation of programs is also a data structure in a primitive type of the language itself, from the Greek words homo meaning the same and icon meaning representation. This makes metaprogramming easier than in a language without this property. To put that another way, homoiconicity is where a program's source code is written as a basic data structure that the programming language knows how to access. For example, imagine a programming language that is particularly good at list manipulation. Now, imagine what would happen if you required programs for that language to be written in the form of lists. The result would be that the program could access its own source code while running, and programmatically reprogram itself on the fly.

Contents

[hide]

1 History2 Use and advantages3 Examples

3.1 Homoiconicity in Lisp3.2 Homoiconicity in Prolog4 See also5 References6 External links[edit] History

The original source is the paper Macro Instruction Extensions of Compiler Languages,[1] according to the early and influential paper TRAC, A Text-Handling Language:[2]

One of the main design goals was that the input script of TRAC (what is typed in by the user) should be identical to the text which guides the internal action of the TRAC processor. In other words, TRAC procedures should be stored in memory as a string of characters exactly as the user typed them at the keyboard. If the TRAC procedures themselves evolve new procedures, these new procedures should also be stated in the same script. The TRAC processor in its action interprets this script as its program. In other words, the TRAC translator program (the processor) effectively converts the computer into a new computer with a new program language -- the TRAC language. At any time, it should be possible to display program or procedural information in the same form as the TRAC processor will act upon it during its execution. It is desirable that the internal character code representation be identical to, or very similar to, the external code representation. In the present TRAC implementation, the internal character representation is based upon ASCII. Because TRAC procedures and text have the same representation inside and outside the processor, the term homoiconic is applicable, from homo meaning the same, and icon meaning representation.

[...]

Following suggestion of McCullough, W. S., based upon terminology due to Peirce, C. S. s McIlroy. M. D., "Macro Instruction Extensions of Compiler Languages," Comm. ACM, p. 214-220; April, 1960.

Alan Kay used and possibly popularized the term "homoiconic" through his use of the term in his 1969 PhD thesis:[3]

A notable group of exceptions to all the previous systems are Interactive LISP [...] and TRAC. Both are functionally oriented (one list, the other string), both talk to the user with one language, and both are "homoiconic" in that their internal and external representations are essentially the same. They both have the ability to dynamically create new functions which may then be elaborated at the users's pleasure. Their only great drawback is that programs written in them look like King Burniburiach's letter to the Sumerians done in Babylonian cuniform! [...][edit] Use and advantages

One advantage of homoiconicity is that extending the language with new concepts typically becomes simpler, as data representing code can be passed between the meta and base layer of the program. The abstract syntax tree of a function may be composed and manipulated as a data structure in the meta layer, and then evaluated.

A typical demonstration of homoiconicity is the meta-circular evaluator.

[edit] Examples

Languages which are considered to be homoiconic include members of the Lisp family, Curl, REBOL, SNOBOL, XSLT, XQuery, TRAC, Io, Ioke, Joy, Factor, Pico, PostScript, Prolog, R, Tcl, Mathematica, and Julia.

In Von Neumann architecture systems (including the vast majority of general purpose computers today), raw machine code also has this property, the data type being bytes in memory.

[edit] Homoiconicity in LispHomoiconicity

Lisp uses S-expressions as an external representation for data and code. S-expressions can be read with the primitive Lisp function READ. READ returns Lisp data: lists, symbols, numbers, strings. The primitive Lisp function EVAL uses Lisp code represented as Lisp data, computes side-effects and returns a result. The result will be printed by the primitive function PRINT, which creates an external S-Expression from Lisp data.

Lisp data, a list using different data types: (sub)lists, symbols, strings and integer numbers.

((:name "john" :age 20) (:name "mary" :age 18) (:name "alice" :age 22))

Lisp code. The example uses lists, symbols and numbers.

(* (sin 1.1) (cos 2.03)) ; in Infix: sin(1.1)*cos(2.03)

Create above expression with the primitive Lisp function LIST and set the variable EXPRESSION to the result

(setf expression (list '* (list 'sin 1.1) (list 'cos 2.03)) )-> (* (SIN 1.1) (COS 2.03)) ; Lisp returns and prints the result(third expression) ; the third element of the expression-> (COS 2.03)

Change the COS term to SIN

(setf (first (third expression)) 'SIN);The expression is now (* (SIN 1.1) (SIN 2.03))

Evaluate the expression

(eval expression)-> 0.7988834

Print the expression to a string

(princ-to-string expression)-> "(* (SIN 1.1) (SIN 2.03))"

Read the expression from a string

(read-from-string "(* (SIN 1.1) (SIN 2.03))")-> (* (SIN 1.1) (SIN 2.03)) ; returns a list of lists, numbers and symbols[edit] Homoiconicity in Prolog1 ?- X is 2*5.X = 10.2 ?- L = (X is 2*5), write_canonical(L).is(_, *(2, 5))L = (X is 2*5).3 ?- L = (ten(X):-(X is 2*5)), write_canonical(L).:-(ten(A), is(A, *(2, 5)))L = (ten(X):-X is 2*5).4 ?- L = (ten(X):-(X is 2*5)), assert(L).L = (ten(X):-X is 2*5).5 ?- ten(X).X = 10.6 ?-

On line 4 we create a new clause. The operator ":-" separates the head and the body of a clause. With assert/1* we add it to the existing clauses(add it to the "database"), so we can call it later. In other languages we would call it "creating a function during runtime". We can also remove clauses from the database with abolish/1, or retract/1.

* The number after the clause's name is the number of arguments it can take (it's also called arity)

We can also query the database to get the body of a clause:

7 ?- clause(ten(X),Y).Y = (X is 2*5).8 ?- clause(ten(X),Y), Y = (X is Z).Y = (X is 2*5),Z = 2*5.9 ?- clause(ten(X),Y), call(Y).X = 10,Y = (10 is 2*5).

"call" is analogous to Lisp's "eval" function.

[edit] See alsoConcatenative programming languageCognitive dimensions of notations, design principles for programming languages' syntax.[edit] References Douglas McIlroy (1960) Macro Instruction Extensions of Compiler Languages Calvin Mooers and L. Peter Deutsch (1965) TRAC, A Text-Handling Language Alan Kay (1969) The Reactive Engine, PhD thesis (Accessed 20061229)[edit] External linksDefinition of Homoiconic at the C2 Wiki.Retrieved from "http://en.wikipedia.org/w/index.php?title=Homoiconicity&oldid=499134234"

One of the main design goals was that the input script of TRAC (what is typed in by the user) should be identical to the text which guides the internal action of the TRAC processor. In other words, TRAC procedures should be stored in memory as a string of characters exactly as the user typed them at the keyboard. If the TRAC procedures themselves evolve new procedures, these new procedures should also be stated in the same script. The TRAC processor in its action interprets this script as its program. In other words, the TRAC translator program (the processor) effectively converts the computer into a new computer with a new program language -- the TRAC language. At any time, it should be possible to display program or procedural information in the same form as the TRAC processor will act upon it during its execution. It is desirable that the internal character code representation be identical to, or very similar to, the external code representation. In the present TRAC implementation, the internal character representation is based upon ASCII. Because TRAC procedures and text have the same representation inside and outside the processor, the term homoiconic is applicable, from homo meaning the same, and icon meaning representation.

[...]

Following suggestion of McCullough, W. S., based upon terminology due to Peirce, C. S. s McIlroy. M. D., "Macro Instruction Extensions of Compiler Languages," Comm. ACM, p. 214-220; April, 1960.

A notable group of exceptions to all the previous systems are Interactive LISP [...] and TRAC. Both are functionally oriented (one list, the other string), both talk to the user with one language, and both are "homoiconic" in that their internal and external representations are essentially the same. They both have the ability to dynamically create new functions which may then be elaborated at the users's pleasure. Their only great drawback is that programs written in them look like King Burniburiach's letter to the Sumerians done in Babylonian cuniform! [...]
本文链接地址:https://www.jiuchutong.com/zhishi/303773.html 转载请保留说明!

上一篇:Mysql数学函数不求人数据库专栏,MySQL(mysql函数nvl)

下一篇:Python与Shell脚本的交互(shell和pycharm)

  • 提升网站四倍流量的外链引流技巧(提升网站四倍流量的方法)

    提升网站四倍流量的外链引流技巧(提升网站四倍流量的方法)

  • 抖音喜欢在哪里关闭(抖音喜欢在哪里设置关闭)

    抖音喜欢在哪里关闭(抖音喜欢在哪里设置关闭)

  • 蓝牙充电仓一直红(蓝牙充电仓一直闪白灯)

    蓝牙充电仓一直红(蓝牙充电仓一直闪白灯)

  • 腾讯只看ta没有了吗(腾讯只看她)

    腾讯只看ta没有了吗(腾讯只看她)

  • 户户通t01信号中断怎么解决(户户通t01信号中断 信号强度为20%)

    户户通t01信号中断怎么解决(户户通t01信号中断 信号强度为20%)

  • 苹果充电发热严重(苹果充电 发烫)

    苹果充电发热严重(苹果充电 发烫)

  • 内存条可以混用吗(内存条可以混用不同品牌吗)

    内存条可以混用吗(内存条可以混用不同品牌吗)

  • iphonese2是双扬声器吗(iphonese是双扬声器)

    iphonese2是双扬声器吗(iphonese是双扬声器)

  • 手机QQ里怎么录屏啊(手机qq怎么录制)

    手机QQ里怎么录屏啊(手机qq怎么录制)

  • 微信发起群聊能拉多少人(微信发起群聊能加多少人)

    微信发起群聊能拉多少人(微信发起群聊能加多少人)

  • kindle屏幕闪烁(kindle屏闪严重且慢)

    kindle屏幕闪烁(kindle屏闪严重且慢)

  • 抖音mcn入驻有什么好处(抖音mcn入驻什么意思)

    抖音mcn入驻有什么好处(抖音mcn入驻什么意思)

  • 硬盘类型mbr和gpt区别(硬盘分区类型mbr和gpt)

    硬盘类型mbr和gpt区别(硬盘分区类型mbr和gpt)

  • 什么是web的标准(web标准包含哪3个方面)

    什么是web的标准(web标准包含哪3个方面)

  • 三星优思版是什么意思(三星优思版2019价格)

    三星优思版是什么意思(三星优思版2019价格)

  • 苹果手机下载不了软件怎么回事(苹果手机下载不了微信)

    苹果手机下载不了软件怎么回事(苹果手机下载不了微信)

  • 计算机病毒是指什么(计算机病毒是指在计算机磁盘上进行自我复制的)

    计算机病毒是指什么(计算机病毒是指在计算机磁盘上进行自我复制的)

  • yy回放怎么没字幕(yy直播回放怎么没有了)

    yy回放怎么没字幕(yy直播回放怎么没有了)

  • iphone电话铃声设置(iphone怎么设置铃声)

    iphone电话铃声设置(iphone怎么设置铃声)

  • 红米蓝牙耳机怎么恢復出厂(红米蓝牙耳机怎么重新配对双耳)

    红米蓝牙耳机怎么恢復出厂(红米蓝牙耳机怎么重新配对双耳)

  • Oppo reno的操作系统是那种(oppo手机的操作系统)

    Oppo reno的操作系统是那种(oppo手机的操作系统)

  • nova5和nova5pro的区别(nova5和nova5pro的外观区别)

    nova5和nova5pro的区别(nova5和nova5pro的外观区别)

  • 华为mate20支持面部解锁吗(华为mate20可以面容支付吗)

    华为mate20支持面部解锁吗(华为mate20可以面容支付吗)

  • 毕业设计-基于微信小程序的校园二手闲置物品交易系统(毕业设计-基于组态软件的流量比值过程控制系统设计)

    毕业设计-基于微信小程序的校园二手闲置物品交易系统(毕业设计-基于组态软件的流量比值过程控制系统设计)

  • 小型微利企业所得税减免政策
  • 企业所得税从业人数怎么填,依据什么填写
  • 企业购买产品
  • 发票上的金额是什么字体
  • 发票的收款人复核怎么写
  • 处置其他权益工具投资时,应按取得的价款
  • 哪些财务指标可以用于判断一个企业即将发生财务危机
  • 存货转固定资产的时点
  • 交易性金融资产入账价值怎么计算
  • 关税的增值税计算公式
  • 国外客户手续费差异账务处理如何做?
  • 开办费所得税清缴时如何调整
  • 企业出售产品
  • 个体户需不需要开立对公账户
  • 发票抬头写错了还能报销吗
  • 2018年企业所得税政策变化
  • 预缴企业所得税税率
  • 增值税零税率发票开具条件
  • 附加税减半征收计提和缴纳的会计分录
  • 土地使用权出让金
  • 建筑企业包工包料
  • 股东赠与计入资本公积,交税
  • 待处理财产损益计入资产负债表哪里
  • 账外资产评估入账固定资产折旧可以税前扣除吗?
  • 网络端口被占用怎么解决
  • 上年发生的费用,下年来得发票,会计分录
  • 如何编制处置固定资产
  • 公司实缴资本有什么风险
  • 知识产权 申请
  • 合同的情势变更是什么
  • 登陆qq网页版手机会有提示吗
  • php图片拼接
  • schedulerv2.exe - schedulerv2是什么进程 有什么用
  • 农民专业合作社税收优惠政策
  • php基础编程题
  • vit详解
  • 什么是长期股权投资法
  • 即征即退增值税怎么申报
  • php7 nginx
  • 出口免税税务备案流程图
  • 用友t3固定资产清理怎么操作
  • dedecms官网
  • mongodb使用场景总结
  • 现金流量表年报期末现金余额
  • 个体户给对方公司开发票会怎样
  • 利润分配转作股本的股利属于什么科目
  • 累计折旧的账务处理
  • 进项税额已经抵扣是什么意思
  • 小规模企业出租不动产增值税税率
  • 拆迁补偿如何进行
  • 劳务费入什么费用
  • 商品销售方式
  • 财报实收资本
  • 税控盘服务费抵扣
  • 货物丢失账务如何处理
  • 18年水利基金税率
  • 年初建账主要录入的内容
  • 会计循环属于什么流程
  • 简述Mysql Explain 命令
  • MySQL为字段添加主键
  • Win7系统关闭怎么办
  • debian和ubuntu命令一样吗
  • ubuntu怎么用linux
  • ssd安装centos7
  • mac验证码无法显示怎么办
  • 笔记本win8为什么不能连无线
  • 如何解决windows蓝屏问题
  • opengl es programming guide
  • 从零基础到入门
  • css中div怎么用
  • 新版unity
  • shader入门
  • js正则匹配特殊符号
  • jquery1.12.4
  • vs2010编译器在哪里?
  • JavaScript程序设计形考任务第一次任务
  • 税务局约谈记录
  • 成都税务局发票查询
  • 上海市国家税务局
  • 零申报的企业残保金怎么申报
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设