位置: 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)

  • 网店的卖家如何维护老顾客(网店卖家如何进货)

    网店的卖家如何维护老顾客(网店卖家如何进货)

  • 小米mix4怎么双击亮屏(小米mix4手机分身在哪里)

    小米mix4怎么双击亮屏(小米mix4手机分身在哪里)

  • 联想笔记本可以用几年(联想笔记本可以加内存条吗)

    联想笔记本可以用几年(联想笔记本可以加内存条吗)

  • 抖音编辑资料修改内容不可用(抖音编辑资料修改次数上限)

    抖音编辑资料修改内容不可用(抖音编辑资料修改次数上限)

  • 抖音音浪10万提现多少(抖音音浪10万提现多少钱)

    抖音音浪10万提现多少(抖音音浪10万提现多少钱)

  • 魅族手机老是自动静音是什么原因(魅族手机老是自动安装软件怎么办)

    魅族手机老是自动静音是什么原因(魅族手机老是自动安装软件怎么办)

  • 连信手机号码对方能看到吗(连信可以通过手机号找人吗)

    连信手机号码对方能看到吗(连信可以通过手机号找人吗)

  • 苹果微信看视频抖动(苹果微信看视频卡顿啥情况)

    苹果微信看视频抖动(苹果微信看视频卡顿啥情况)

  • 华为nova7se颜色有几种(华为nova7se颜色怎么调)

    华为nova7se颜色有几种(华为nova7se颜色怎么调)

  • 抖音号搜索为空什么意思(抖音号搜索为空怎样设置)

    抖音号搜索为空什么意思(抖音号搜索为空怎样设置)

  • cmmi3认证是什么(cmmi3认证证书中文翻译)

    cmmi3认证是什么(cmmi3认证证书中文翻译)

  • 小米10pro屏幕是三星的吗(小米10pro屏幕是三星还是国产)

    小米10pro屏幕是三星的吗(小米10pro屏幕是三星还是国产)

  • 爱奇艺不能自动播放下一集怎么回事(爱奇艺不能自动播放下一集)

    爱奇艺不能自动播放下一集怎么回事(爱奇艺不能自动播放下一集)

  • 小米6x充电器接口型号(小米6x充电线接口)

    小米6x充电器接口型号(小米6x充电线接口)

  • 爱奇艺的杜比音效怎么关闭(爱奇艺的杜比音效是真的吗)

    爱奇艺的杜比音效怎么关闭(爱奇艺的杜比音效是真的吗)

  • 华为mate20下载的文件在哪里(华为mate20下载的软件找不到)

    华为mate20下载的文件在哪里(华为mate20下载的软件找不到)

  • gps是导航吗(gps导航啥意思)

    gps是导航吗(gps导航啥意思)

  • 如何更改word数字字体(word文档怎么修改数字格式)

    如何更改word数字字体(word文档怎么修改数字格式)

  • 淘宝个人中心在哪里找(淘宝个人中心在哪儿找啊)

    淘宝个人中心在哪里找(淘宝个人中心在哪儿找啊)

  • 乐视会员怎么取消自动续费(乐视会员怎么取消自动续费不了)

    乐视会员怎么取消自动续费(乐视会员怎么取消自动续费不了)

  • 微信的草稿箱在哪里看(微信的草稿箱在哪里可以找到)

    微信的草稿箱在哪里看(微信的草稿箱在哪里可以找到)

  • qq友谊的小船是单向还是双向(qq友谊的小船是单向)

    qq友谊的小船是单向还是双向(qq友谊的小船是单向)

  • 淘宝动态评分怎么提升(淘宝动态评分怎么看谁打的)

    淘宝动态评分怎么提升(淘宝动态评分怎么看谁打的)

  • 快手恢复本地作品集(快手恢复本地作品怎么弄)

    快手恢复本地作品集(快手恢复本地作品怎么弄)

  • 能量罩怎么获取(能量套装怎么做)

    能量罩怎么获取(能量套装怎么做)

  • iphonex保修多久(苹果x保修期多久查询)

    iphonex保修多久(苹果x保修期多久查询)

  • macos big sur怎么关闭右上角通知? 永久关闭finalcutPro通知的技巧(macos big sur怎么恢复出厂设置)

    macos big sur怎么关闭右上角通知? 永久关闭finalcutPro通知的技巧(macos big sur怎么恢复出厂设置)

  • 工衣工帽清洗费税率是多少
  • 办理出口退税时间要求
  • 税务人员岗位有哪些
  • 所得税费用属于什么科目借贷方向
  • 母子公司换股协议
  • 税务季报利润表的本年累计可以更改吗
  • 总分机构是什么
  • 保险公司收车船使用税吗
  • 运输企业车辆折旧一次性折旧
  • 全资收购企业需要交税吗
  • 填仓2021
  • 企业的两金是哪两金
  • 其他应付款转为营业外收入要交税吗
  • 用友怎么结转本期损益
  • 房地产企业增值税税率
  • 个税手续费返还政策最新规定2023
  • 领用自产应税消费品负担的消费税计入在建工程成本吗
  • 出口发票税率是怎么算的
  • 客户回款扣除的手续费会计分录怎么做?
  • 公车补贴计入什么科目
  • 突然收到银联入账收入怎么办
  • 外购商品计入
  • 项目一次性奖励会计分录怎么处理
  • 下个月的发票可以报销上个月的费用吗
  • 增值税发票抵扣联丢失怎么办
  • 简并增值税税率政策解读
  • 自然人税收申报显示申报失败:未选择纳税人
  • 罚款收入增值税税率是多少
  • 视同销售收入是否缴纳企业所得税?
  • 往来款核销需要如何确认
  • 城镇土地使用税征收标准及计算方法
  • 刚装好的服务器怎么安装
  • 公司处理陈旧物怎么处理
  • 一次性开票分期确认收入如何纳税申报
  • 第三方开发是什么意思
  • php中运算符
  • PHP:stream_context_get_options()的用法_Stream函数
  • 应交营业税计算公式
  • vue项目中技巧知识点
  • 生产企业可以抵扣进项税的
  • 基于springboot的oa
  • 开发成本属于什么类型科目
  • php使用curl
  • 最新预提房租会计分录
  • 转增资本属于什么会计科目
  • 计提工资扣社保的凭证
  • 数据类型所占的字节
  • mongodb在windows上的安装
  • 小规模纳税人工资薪金怎么申报
  • 个体工商户怎么变更法人
  • 房产互换如何交税费
  • 用人单位性质怎么填
  • 预期损失el
  • 用友电子报表怎么生成
  • 研发设备的折旧计入研发费用吗
  • 补发工资怎么补发
  • 提取保险责任准备金怎么计算
  • 出口收汇手续费需要在出口退税时扣除吗
  • 公司账户没有钱怎么发工资
  • 金税盘清卡怎么操作视频
  • 物业公司开专票税率是多少
  • 新手会计做账怎么做账
  • linux中df命令详解
  • ubuntu configure
  • ubuntu安装配置静态ip地址
  • c1.exe是什么
  • win10怎么设置宽带连接上网
  • cocos2dx入门
  • python的文件操作中找不到文件应该如何处理
  • angularjs阻止冒泡
  • jquery 入门
  • python元组和数组
  • 物理引擎演示
  • python遍历列表判断相同元素
  • 浅谈关于混合模式教学的看法
  • jquery详解
  • 重庆电子税务局网页版登录
  • 增值税减免税备案
  • 地税局属于省直单位吗
  • 小型贸易企业公司有哪些
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设