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

  • 微信去电铃声怎么搞(微信去电铃声怎么设置自定义铃声)

    微信去电铃声怎么搞(微信去电铃声怎么设置自定义铃声)

  • 为什么qq关联看不到别人给对方发的信息(为什么qq关联看不到对方)

    为什么qq关联看不到别人给对方发的信息(为什么qq关联看不到对方)

  • 小米9se触控失灵(小米9se触控失灵怎么处理)

    小米9se触控失灵(小米9se触控失灵怎么处理)

  • 苹果8a1863是什么版本(苹果8a1863是国行吗)

    苹果8a1863是什么版本(苹果8a1863是国行吗)

  • 美团众包审核没有通过怎么办(美团众包初审未通过,我们会在1-3个工作日)

    美团众包审核没有通过怎么办(美团众包初审未通过,我们会在1-3个工作日)

  • 文件许可权错误无法保存(由于文件许可权错误)

    文件许可权错误无法保存(由于文件许可权错误)

  • 抖音怎样解除火山绑定(抖音怎样解除火山版同步)

    抖音怎样解除火山绑定(抖音怎样解除火山版同步)

  • 苹果停留控制什么意思(iphone停留控制有什么用)

    苹果停留控制什么意思(iphone停留控制有什么用)

  • qq添加失败请稍后再试是什么意思(qq添加失败请勿频繁操作是什么意思)

    qq添加失败请稍后再试是什么意思(qq添加失败请勿频繁操作是什么意思)

  • ddc/ci一会儿开一会儿关怎么回事(ddc/ci一会开一会关)

    ddc/ci一会儿开一会儿关怎么回事(ddc/ci一会开一会关)

  • 超话帖子发送成功却没有显示(超话帖子发不出去怎么回事)

    超话帖子发送成功却没有显示(超话帖子发不出去怎么回事)

  • 高通765g相当于骁龙多少(高通765g相当于天机多少)

    高通765g相当于骁龙多少(高通765g相当于天机多少)

  • 抖音为什么加了慢动作就没有音乐了(抖音为什么加了音乐没有原声)

    抖音为什么加了慢动作就没有音乐了(抖音为什么加了音乐没有原声)

  • 手机耳机可以在电脑上不能用吗(手机耳机可以在ipad上用吗)

    手机耳机可以在电脑上不能用吗(手机耳机可以在ipad上用吗)

  • 苹果x跟苹果xsmax区别(苹果X跟苹果Xsmax)

    苹果x跟苹果xsmax区别(苹果X跟苹果Xsmax)

  • 220伏电器在110伏电压下能用吗(220伏电器在110伏电压下能用吗?)

    220伏电器在110伏电压下能用吗(220伏电器在110伏电压下能用吗?)

  • 苹果11只能设置一个面容吗(苹果只能设置一个人的面容吗)

    苹果11只能设置一个面容吗(苹果只能设置一个人的面容吗)

  • ps里怎么调整图像大小(ps里怎么调整图片大小还保持清晰)

    ps里怎么调整图像大小(ps里怎么调整图片大小还保持清晰)

  • 爱奇艺弹幕字体颜色(爱奇艺弹幕字体跟随系统)

    爱奇艺弹幕字体颜色(爱奇艺弹幕字体跟随系统)

  • oppo怎么强制开机(oppo怎么强制开机 只震动)

    oppo怎么强制开机(oppo怎么强制开机 只震动)

  • 拼多多怎么给客服发视频(拼多多怎么给客户留联系方式)

    拼多多怎么给客服发视频(拼多多怎么给客户留联系方式)

  • 苹果1164g够用吗

    苹果1164g够用吗

  • win10照片收藏夹在哪(window10照片收藏)

    win10照片收藏夹在哪(window10照片收藏)

  • 手机淘宝查看历史订单(手机淘宝查看历史账单)

    手机淘宝查看历史订单(手机淘宝查看历史账单)

  • 想换手机号可是绑定银行卡怎么办(想换手机号了)

    想换手机号可是绑定银行卡怎么办(想换手机号了)

  • 笔记本电脑发烫(笔记本电脑发烫怎么解决)

    笔记本电脑发烫(笔记本电脑发烫怎么解决)

  • 什么是全民k歌(什么是全民K歌客户端)

    什么是全民k歌(什么是全民K歌客户端)

  • 戈佐岛上的Cittadella城堡,马耳他 (© Davide Seddio/Getty Images)(戈佐西餐厅)

    戈佐岛上的Cittadella城堡,马耳他 (© Davide Seddio/Getty Images)(戈佐西餐厅)

  • 商贸企业辅导期是什么
  • 摊余成本的构成内容
  • 公司注销单位社保欠费怎么处理
  • 支付宝理财提现到银行卡有费用吗
  • 无形资产的出售的会计处理
  • 电子发票红字发票怎么开
  • 可以向国外账户汇人民币吗
  • 权益法核算投资收益
  • 给退休工人发工资怎么入账
  • 企业所得税跨期费用的相关规定
  • 把公司的设备弄坏了怎么办
  • 成本暂估跨年度要怎么处理?
  • 个人挂靠公司承接工程如何做会计处理?
  • 税务审计什么时候进行
  • 建筑业预交的增值税
  • 金税控系统发票打印设置
  • 公司个税申报是什么意思
  • 试用期可以不交五险一金吗
  • 生产企业出口退税申报系统详细操作流程
  • 企业筹建期间可以自己发农民工工资么
  • 升级华为鸿蒙系统怎么样
  • 小企业执行新会计准则吗
  • 以前年度损益调整借贷方向
  • 付款给对方怎么做分录
  • 商贸企业零部件出口退税政策
  • 模具成本怎么核算
  • 农业种植公司要纳税吗
  • 收到对方公司开的电子专票怎么入账
  • 保总保安服务有限公司
  • PHP:file_put_contents()的用法_Filesystem函数
  • 在产品定额工时怎么算
  • php中常量与变量的区别
  • 第二季度所得税怎么算
  • 电子发票有哪些种类
  • 进销项抵扣规则
  • 知识产权专利费包括哪些费用
  • Win11 KB5025239 / KB5025224 累积更新今日发布
  • ghostnet改进
  • 管家婆付款单凭证科目如何修改
  • 违约金税目
  • 生产型企业出口退税会计分录
  • js 数组remove
  • python输出inf
  • jsp连接数据库的步骤
  • mysql客户端怎么使用
  • select
  • 税费退库怎么做账
  • 长期应付款科目的涉税风险
  • 税控盘反写是不是说明税都已经成功申报了
  • 小规模纳税人销售要交税吗
  • 水利工程施工税率是多少
  • 可供出售金融资产包括哪些内容
  • 赠送购物券的会计处理
  • 实收资本小于注册资本账务处理
  • mysql 厂家
  • 如何启动vmware authorization service
  • win10改win8.1
  • centos7如何扩展根分区空间
  • fedora vlc
  • win8打开运行窗口
  • windows10mobile官网
  • 如何知道文件的解压密码
  • centos6基础命令
  • Ubuntu如何安装软件
  • win2008怎么查看隐藏文件
  • xp 桌面图标
  • linux无法登陆
  • win10预览版bug
  • win10无法安装无线显示器
  • TestOpenGL
  • 解读css发展历史简述
  • Android-ViewPager使用示例
  • 动作手游排行榜2020前十名
  • python脚本代码大全
  • unity获取物体的位置
  • unity编译速度吃什么硬件?
  • jquery控制display属性
  • python嵌套列表怎么遍历
  • 消费税申报详细流程图
  • 给派出所写情况说明房屋情况怎么写啊
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设