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

  • 支付宝真实姓名怎么隐藏(支付宝真实姓名怎么设置隐藏)

    支付宝真实姓名怎么隐藏(支付宝真实姓名怎么设置隐藏)

  • 电脑出现windows找不到文件c:/program.(电脑出现windows资源管理器已停止工作)

    电脑出现windows找不到文件c:/program.(电脑出现windows资源管理器已停止工作)

  • tt语音红钻在哪里可以使用(tt语音红钻在哪里兑换礼包)

    tt语音红钻在哪里可以使用(tt语音红钻在哪里兑换礼包)

  • 手机qq语音气泡怎么恢复默认(手机qq语音气泡怎么设置方法)

    手机qq语音气泡怎么恢复默认(手机qq语音气泡怎么设置方法)

  • 华为手机布局已锁定怎么消除(华为手机的布局怎么变回来了)

    华为手机布局已锁定怎么消除(华为手机的布局怎么变回来了)

  • 三星note8黑屏但屏幕可触动(三星note8屏幕黑屏能触)

    三星note8黑屏但屏幕可触动(三星note8屏幕黑屏能触)

  • 华为p40有定位功能吗(华为p40定位功能在哪里)

    华为p40有定位功能吗(华为p40定位功能在哪里)

  • 荣耀play3支持nfc吗(荣耀play3支持电信卡吗)

    荣耀play3支持nfc吗(荣耀play3支持电信卡吗)

  • 苹果闹钟稍后提醒什么意思(苹果闹钟稍后提醒时间是多久)

    苹果闹钟稍后提醒什么意思(苹果闹钟稍后提醒时间是多久)

  • 华为nova3i支持nfc功能吗(华为nova3i支持电信高清通话吗)

    华为nova3i支持nfc功能吗(华为nova3i支持电信高清通话吗)

  • 荣耀9x支不支持快充(荣耀9x支不支持多屏协同)

    荣耀9x支不支持快充(荣耀9x支不支持多屏协同)

  • 怎样将手机软件转入内存卡(怎样将手机软件隐藏起来不被发现)

    怎样将手机软件转入内存卡(怎样将手机软件隐藏起来不被发现)

  • 努比亚红魔3S有耳机孔吗(努比亚红魔3s有耳机吗)

    努比亚红魔3S有耳机孔吗(努比亚红魔3s有耳机吗)

  • 如何在苹果手机上建立文件夹(如何在苹果手机上安装安卓软件)

    如何在苹果手机上建立文件夹(如何在苹果手机上安装安卓软件)

  • 华为的位置信息耗电吗(华为的位置信息用的哪个导航系统)

    华为的位置信息耗电吗(华为的位置信息用的哪个导航系统)

  • 拼多多场景推广怎么弄(拼多多场景推广没有曝光是怎么回事)

    拼多多场景推广怎么弄(拼多多场景推广没有曝光是怎么回事)

  • 摄像头聚焦多少毫米好(摄像头聚焦多少看的远)

    摄像头聚焦多少毫米好(摄像头聚焦多少看的远)

  • 华为手机怎么开QQ音乐通知栏(华为手机怎么开启5g)

    华为手机怎么开QQ音乐通知栏(华为手机怎么开启5g)

  • 苹果手表蜂窝怎么开通(苹果手表蜂窝的功能)

    苹果手表蜂窝怎么开通(苹果手表蜂窝的功能)

  • 网页版b站怎么缓存(网页版b站怎么截图)

    网页版b站怎么缓存(网页版b站怎么截图)

  • 快手能查到对方位置吗(快手能查到对方微信号)

    快手能查到对方位置吗(快手能查到对方微信号)

  • 【申请加入New Bing遇到的问题:当前无法使用此页面,cn.bing.com 重定向次数过多】(加入申请理由怎么写)

    【申请加入New Bing遇到的问题:当前无法使用此页面,cn.bing.com 重定向次数过多】(加入申请理由怎么写)

  • 山东省增值税发票勾选认证平台
  • 基本户可以直接转账给个人吗
  • 建筑企业开票都开什么
  • 广告公司个体户自己可以开发票
  • 会议服务费怎么开
  • 安装费发票备注栏怎么填
  • 甲供材料税金如何结算
  • 在分公司关闭过程中,资产损失怎么申报扣除
  • 其他应收款用什么表示
  • 办公室低值易耗品管理员职责
  • 土地投资入股是否需要发票作为企业所得税税前扣除凭证
  • 接受土地使用权作为投资属于什么凭证
  • 餐饮赠送菜品怎么说
  • 新会计准则开办费装修费计入什么科目
  • 预收账款多说明什么
  • 南方建筑主编
  • 个体户超过3万怎么纳税
  • 增值税如何确认
  • 新企业所得税法规定的企业包括
  • 2020国家生育津贴多少钱
  • 收到工程款退回的账务处理
  • 长期股权投资稀释
  • 企业购买股票投资
  • 净现值是否可行
  • 免抵退不得免征和抵扣是什么意思
  • php介绍
  • 铁路货物运输代理
  • php7.0
  • 电脑语言栏不见了,打不出汉字
  • PHP:pcntl_exec()的用法_PCNTL函数
  • 小规模核定征收突然转查账
  • 成本核算方法主要有哪些
  • 外商投资的企业再投资
  • 个体户变更为有限公司成立时间
  • 劳务派遣如何做绩效考核
  • 轨迹评价
  • 汇算清缴怎么调减
  • thinkphp域名路由
  • 员工旅游费的税率是多少
  • vue set up
  • 基于Java+SpringBoot+Vue前后端分离仓库管理系统设计实现
  • 出租包装物五五摊销法分录例题
  • php原生导出excel表单元格格式
  • php接口开发详解
  • 研发入库的产品销售出库怎样做账
  • 应收利息会计分局
  • 只有发票没有银行怎么办
  • 个税申报漏报人怎么办
  • LVS负载均衡群集的常用调度算法包含哪几种?
  • 饲料加工企业可以转让吗
  • 差旅费需要缴纳增值税吗
  • 还有什么服务啊
  • 科目余额表科目
  • 金税四期对企业纳税管理影响分析
  • 银行承兑汇票和银行汇票的区别
  • 员工罚款从工资中代扣
  • ukey要交服务费吗
  • 期末结转生产成本的账户
  • 进项税额转出的几种情况
  • 汽车折旧年限及残值率是多少
  • 为什么总成本费用不变
  • 总账建账的原则包括
  • 无形资产占公司比例
  • 解析关于sql语句的实现
  • mysql允许字段为空
  • Mysql 5.7.17 winx64在win7上的安装教程
  • winxp更新到win10
  • Cocos2dx3.2 CrazyTetris 单线裁剪 对于判断消除的思考(一)
  • python的nltk
  • python语言如何获取随机整数
  • android怎么保存项目
  • shell的变量分为哪三种
  • unity怎么调用方法
  • javascript类定义
  • javascript例题
  • android获取屏幕大小
  • 普通发票开具系统
  • 鉴证服务是指什么
  • 查账征收个人经营所得税怎么申报
  • 2021年四川医保缴费截止时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设