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

  • 苹果手机相册拼图怎么拼(苹果手机相册拼图怎么做)

    苹果手机相册拼图怎么拼(苹果手机相册拼图怎么做)

  • 小米手机充电提示音怎么自定义(小米手机充电提示灯怎么设置)

    小米手机充电提示音怎么自定义(小米手机充电提示灯怎么设置)

  • 华为荣耀9x有没有智能助手(华为荣耀9x有没有红外线功能)

    华为荣耀9x有没有智能助手(华为荣耀9x有没有红外线功能)

  • 苹果11pro屏幕是几寸(苹果11pro屏幕是lcd还是oled)

    苹果11pro屏幕是几寸(苹果11pro屏幕是lcd还是oled)

  • 抖音看不到自己动态(抖音看不到自己的评论怎么回事?)

    抖音看不到自己动态(抖音看不到自己的评论怎么回事?)

  • zenly显示5分钟前是什么意思(zenly显示的几分钟前)

    zenly显示5分钟前是什么意思(zenly显示的几分钟前)

  • 天翼超高清的投屏方式(天翼超高清投屏二维码)

    天翼超高清的投屏方式(天翼超高清投屏二维码)

  • 计算机键盘上的ctrl键称为(计算机键盘上的顿号怎么打)

    计算机键盘上的ctrl键称为(计算机键盘上的顿号怎么打)

  • 虚拟网月费可以取消吗(虚拟网月费可以退回吗)

    虚拟网月费可以取消吗(虚拟网月费可以退回吗)

  • 淘宝账号注销了可以再用同一个号码注册吗(淘宝账号注销了怎么查看订单)

    淘宝账号注销了可以再用同一个号码注册吗(淘宝账号注销了怎么查看订单)

  • 哔哩哔哩转正用户是什么意思(哔哩哔哩转正入口在哪)

    哔哩哔哩转正用户是什么意思(哔哩哔哩转正入口在哪)

  • 苹果手机微信扬声器声音小怎么回事(苹果手机微信扬声器打不开了怎么办)

    苹果手机微信扬声器声音小怎么回事(苹果手机微信扬声器打不开了怎么办)

  • 路由器黄灯闪烁(华为路由器黄灯闪烁)

    路由器黄灯闪烁(华为路由器黄灯闪烁)

  • 5g无线帧长是多少ms(5gnr无线帧长)

    5g无线帧长是多少ms(5gnr无线帧长)

  • 手机后台在哪里(oppo手机怎么关闭运行程序)

    手机后台在哪里(oppo手机怎么关闭运行程序)

  • bilibili怎么关闭循环播放(哔哩哔哩怎么关闭会员续费)

    bilibili怎么关闭循环播放(哔哩哔哩怎么关闭会员续费)

  • 抖音能设置指定人看吗(抖音能设置指定人搜索不到自己吗)

    抖音能设置指定人看吗(抖音能设置指定人搜索不到自己吗)

  • 苹果密保在哪里设置(苹果密保在哪里看)

    苹果密保在哪里设置(苹果密保在哪里看)

  • 怎么调取微信删除的聊天记录(怎么调取微信删除的账单)

    怎么调取微信删除的聊天记录(怎么调取微信删除的账单)

  • ipad为什么白屏(ipad为什么突然白屏)

    ipad为什么白屏(ipad为什么突然白屏)

  • 手机怎么在图片上编辑文字(手机怎么在图片上打字)

    手机怎么在图片上编辑文字(手机怎么在图片上打字)

  • 华为mate30怎么关闭负一屏(华为mate30怎么关闭悬浮球)

    华为mate30怎么关闭负一屏(华为mate30怎么关闭悬浮球)

  • 如何把淘宝界面变回去(怎么把淘宝设置在桌面)

    如何把淘宝界面变回去(怎么把淘宝设置在桌面)

  • 怎么查看情侣空间历史(怎么查看情侣空间历史记录所有的前任)

    怎么查看情侣空间历史(怎么查看情侣空间历史记录所有的前任)

  • iphone怎么设置小爱(iphone怎么设置小组件)

    iphone怎么设置小爱(iphone怎么设置小组件)

  • 机顶盒跟网络电视切换(机顶盒和网络)

    机顶盒跟网络电视切换(机顶盒和网络)

  • vivox21手机屏幕失灵(vivox21手机屏幕不亮了但是开机的)

    vivox21手机屏幕失灵(vivox21手机屏幕不亮了但是开机的)

  • 华为p30能拍多远(华为p30pro能拍多远)

    华为p30能拍多远(华为p30pro能拍多远)

  • 调制解调器的作用是(调制解调器的作用是什么单选题)

    调制解调器的作用是(调制解调器的作用是什么单选题)

  • 手机qq怎么看屏蔽的人(手机qq怎么看屏蔽了哪些人)

    手机qq怎么看屏蔽的人(手机qq怎么看屏蔽了哪些人)

  • 微软 Win11 预览版已登陆 Azure 虚拟桌面:支持 TPM 2.0 和安全启动(微软win11预览版)

    微软 Win11 预览版已登陆 Azure 虚拟桌面:支持 TPM 2.0 和安全启动(微软win11预览版)

  • 保本理财增值税可以开票吗怎么开
  • 小规模纳税属于什么类型
  • 合伙律师事务所的合伙人必须是
  • 固定资产怎么进行折旧处理
  • 发票第二年是否可以作废
  • 领用包装物的会计分录
  • 增值税加计抵减最新政策2022
  • 税务机关六位地区编码是什么
  • 生产成本二级科目有工资吗
  • 外贸企业一般纳税人申报
  • 银行的划分标准
  • 预收物业费如何填报申报表
  • 没有营业收入要报税吗
  • 进口小汽车消费税组成计税价格
  • 抵债的货物按什么算增值税
  • 自制半成品具体如何处理账务?
  • 有发票的福利费可以不交个税吗
  • 刻章的发票怎么做分录
  • 小微企业免征增值税优惠
  • 税前可以扣除的管理费用计算公式
  • 免交的增值税计入什么科目
  • 股息收入属于应税收入吗
  • 工业企业采购原材料
  • 股东认缴和实缴的会计分录
  • 受托加工物资入库流程
  • 广告业财政拨款包括哪些
  • 跨年的发票冲红
  • php留言板的简单编写
  • 苹果电脑优酷视频打不开
  • 委托加工物资企业原材料都是自己采购
  • php escapeshellarg
  • 新准则规定
  • 所得税和应交所得税
  • 超期未认证的进项发票怎么处理
  • 从国际空间站看木星
  • 布列塔尼岛屿
  • phpstudy配置https
  • 企业所得税申报表模板
  • 合同负债和预收负债的区别
  • 营改增后一般纳税人缴纳增值税彩用简易征收3%
  • 增值税专用发票抵扣期限
  • 图书免税?
  • 人民法院司法警察警用装备
  • okhttp3源码分析
  • linux db2安装与配置
  • 承租方承担税费
  • 累计销售额怎么算
  • 承兑汇票可以当现金借给别人用吗
  • sql server 2008打开界面
  • 盘亏的主要原因是什么
  • 一般纳税人适用3%税率情况
  • 以前年度的费用发票怎么入账
  • 现金短缺与溢余解析
  • 简易办法征收增值税有几种情况
  • 在建工程什么时候用
  • 盈利能力分析的理论意义和现实意义
  • 股东打到公帐上怎么做账
  • 应付利润科目
  • 计提了减值准备怎么算折旧额
  • 签订购货合同,计划下月购入的固定资产
  • mysql error1418
  • solaris 安装
  • 电脑开机时出现红色三角形
  • ubuntu 20.04.1 lts
  • win7系统如何将插孔设置为ac97前面板
  • win7还原按钮
  • win7不允许我更改系统设置
  • win7怎么查是不是正版
  • cocos2dx怎么安装
  • linux文件目录管理命令
  • 批处理实例
  • css颜色值正确的表达形式
  • jqgrid api中文手册
  • Javascript中的this
  • NGUI简介
  • jQuery progressbar通过Ajax请求实现后台进度实时功能
  • 简单的jquery插件实例
  • jquery实现自动轮播
  • 不配合税务检查的法律责任
  • 河北电子税务局怎么使用
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设