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

  • u盘开机锁(u盘开机锁)(u盘锁住了怎么打开)

    u盘开机锁(u盘开机锁)(u盘锁住了怎么打开)

  • 新疆政务服务怎么更改手机号码(新疆政务服务怎么查核酸报告)

    新疆政务服务怎么更改手机号码(新疆政务服务怎么查核酸报告)

  • 12306有电子报销凭证吗(12306电子报销单)

    12306有电子报销凭证吗(12306电子报销单)

  • excel如何制作折线图表(excel如何做折叠)

    excel如何制作折线图表(excel如何做折叠)

  • 微信按住说话需要设置吗(微信按住说话需要流量吗)

    微信按住说话需要设置吗(微信按住说话需要流量吗)

  • vivo x27彩铃怎么设置(vivo手机彩铃怎么弄)

    vivo x27彩铃怎么设置(vivo手机彩铃怎么弄)

  • 咪咕音乐系统内部异常怎么办(咪咕音乐界面)

    咪咕音乐系统内部异常怎么办(咪咕音乐界面)

  • 苹果截图设置在哪里(苹果截图在哪里设置?)

    苹果截图设置在哪里(苹果截图在哪里设置?)

  • razer synapse是什么(razer that)

    razer synapse是什么(razer that)

  • 微信安装包在哪里(微信安装包在哪个位置)

    微信安装包在哪里(微信安装包在哪个位置)

  • 小米黑暗模式怎么开启(小米设置黑暗模式)

    小米黑暗模式怎么开启(小米设置黑暗模式)

  • 分辨率每英寸96x96点是多少(分辨率每英寸96×96点是多少像素)

    分辨率每英寸96x96点是多少(分辨率每英寸96×96点是多少像素)

  • 苹果11送耳机吗(苹果11里面送耳机吗)

    苹果11送耳机吗(苹果11里面送耳机吗)

  • 华为p40pro屏幕边缘发绿(华为P40PRO屏幕边一条绿线)

    华为p40pro屏幕边缘发绿(华为P40PRO屏幕边一条绿线)

  • 拍照怎么开闪光灯(苹果拍照怎么开闪光)

    拍照怎么开闪光灯(苹果拍照怎么开闪光)

  • 手机寿命取决于什么(手机的寿命跟什么有关系)

    手机寿命取决于什么(手机的寿命跟什么有关系)

  • 怎么查手机屏幕刷新率(怎么查手机屏幕是哪个厂家的)

    怎么查手机屏幕刷新率(怎么查手机屏幕是哪个厂家的)

  • 目录怎么自动生成页数(目录怎么自动生成后怎么调整)

    目录怎么自动生成页数(目录怎么自动生成后怎么调整)

  • 荣耀10nfc感应区在哪(荣耀10nfc感应区在哪里图解)

    荣耀10nfc感应区在哪(荣耀10nfc感应区在哪里图解)

  • 手机色彩突然变了(手机色彩突然变成x光一样)

    手机色彩突然变了(手机色彩突然变成x光一样)

  • 微信实名认证在哪里看(微信实名认证在哪里改完零钱还在吗)

    微信实名认证在哪里看(微信实名认证在哪里改完零钱还在吗)

  • 戴尔笔记本电脑将预装win8改win7系统教程详细图解(戴尔笔记本电脑哪款性价比最高)

    戴尔笔记本电脑将预装win8改win7系统教程详细图解(戴尔笔记本电脑哪款性价比最高)

  • 将MS-DOS 6.22装入U盘和硬盘的方法(ms-dos安装)

    将MS-DOS 6.22装入U盘和硬盘的方法(ms-dos安装)

  • agfaclnk.exe进程有什么作用 agfaclnk是什么进程(打开进程失败)

    agfaclnk.exe进程有什么作用 agfaclnk是什么进程(打开进程失败)

  • React基础-JSX语法列表渲染详解(react js 教程)

    React基础-JSX语法列表渲染详解(react js 教程)

  • 【目标检测】YOLOv5模型从大变小,发生了什么?(目标检测yolo)

    【目标检测】YOLOv5模型从大变小,发生了什么?(目标检测yolo)

  • python异常捕捉对字符串进行判断(python捕获异常继续执行)

    python异常捕捉对字符串进行判断(python捕获异常继续执行)

  • 「上海名媛群」低价拼顶级下午茶、酒店、奢侈品…「名媛」的英文是什么?(想要上海名媛群群号)

    「上海名媛群」低价拼顶级下午茶、酒店、奢侈品…「名媛」的英文是什么?(想要上海名媛群群号)

  • DEDECMS织梦整站动态化或整站静态化设置教程(2020织梦建站教程全集)

    DEDECMS织梦整站动态化或整站静态化设置教程(2020织梦建站教程全集)

  • 增值税纳税申报表在哪里查询
  • 居民和非居民企业的概念
  • 小规模纳税人劳务派遣差额征税税率
  • 个体工商户申报个税是按月按季度
  • 什么经营范围可以开电费发票
  • 投资子公司亏损如何入账
  • 向境外个人支付咨询费如何算税
  • 销项税的抵扣
  • 所得税汇算清缴分录怎么做
  • 已投入使用的机器设备才能计提折旧对吗
  • 国资委无偿划拨资产不上税吗
  • 一般纳税人计提水利基金会计分录
  • 中外合资房地产公司
  • 公司车子的保养费怎么算
  • 拖欠供应商货款
  • 固定资产报废废铁收入需要交税吗
  • 三证合一之后还有税务登记证吗
  • 盘盈固定资产冲销啥科目
  • 农村承包土地能卖土吗
  • 小规模增值税纳税申报表
  • 贸易公司购进原材料会计分录
  • 股票红利税如何征收
  • 个税没有扣除项,需要填写和确认吗
  • 勾选认证的发票怎么确认签名
  • 预付款比例怎么算
  • 鸿蒙系统怎么同步数据
  • WIN10显示缩略图
  • 应收账款无法收回确认为坏账会计分录
  • 营业外收入冲减销售费用
  • 退回多收款项开具发票原发票需要退回吗
  • win11安装程序提示非管理员账号
  • 拍卖获得收入个税
  • 研发费用的支出类型有哪些
  • 股东以债权出资,公司怎么处理
  • ros call
  • 会计分录的表现形式有
  • source map
  • framework怎么用
  • react 刷新
  • 前端软件开发工具
  • 主营业务毛利率公式
  • 会计购入材料入什么科目
  • 运筹最优化方法有哪些
  • bug的定位和跟踪
  • 非货币性资产交换和债务重组的区别
  • 企业内部培训费用
  • 怎么把其他应收款借方余额转出
  • DB2 9(Viper)快速入门
  • 买车哪些费用可以计入固定资产
  • 工程赔付款属于什么科目
  • 包装的设计要遵循哪些要求?
  • 固定资产是怎么管理的
  • 长期待摊费用该怎么记账
  • 计提生产产品的机器设备的折旧应借记制造费用科目
  • 营改增后出售土地如何缴纳增值税
  • 社保的生育险按照什么比例报销
  • 事业单位收个人所得税吗
  • 递延纳税筹划策略研究
  • 企业认缴的资金放哪里
  • mysql实时监控工具
  • 游戏卡怎么打开
  • linux中安装vim命令
  • windowsupdate.diagcab
  • 重装系统后没声音怎么解决win7
  • centos6.x下安装maven CentOS自动安装Maven的方法
  • mozilla是啥
  • GhostXP_SP3活力版V3.0_系统之家首发
  • P2P Networking2.exe - P2P Networking2是什么进程 有什么用
  • SCP 方便的Linux文件互传
  • easyui combobox onchange
  • 2012年腾讯股价多少
  • js的设计模式有哪些
  • ViewGroup onInterceptTouchEvent,ViewGroup onTouchEvent,View onTouchEvent执行顺序说明
  • linux两个版本
  • java 视频教程
  • jquery修改href
  • jquery mobile怎么样
  • 个体 税务登记
  • 企业年度总收入指的是什么意思
  • 税控盘怎么看收入
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设