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

  • 苹果可以换主题风格吗(苹果可以换主题和字体吗)

    苹果可以换主题风格吗(苹果可以换主题和字体吗)

  • 小米手环6怎么换自定义壁纸(小米手环6怎么调时间)

    小米手环6怎么换自定义壁纸(小米手环6怎么调时间)

  • 抖音申诉没有通过怎么办(抖音申诉没有通过)

    抖音申诉没有通过怎么办(抖音申诉没有通过)

  • iphone辅助触控没反应(iphone辅助触控开着但是不见了)

    iphone辅助触控没反应(iphone辅助触控开着但是不见了)

  • 通过微信号添加的好友是怎么回事(通过微信号添加的好友怎么查手机号)

    通过微信号添加的好友是怎么回事(通过微信号添加的好友怎么查手机号)

  • 宽带500兆网速是多少(宽带500兆网速是指的流量吗?)

    宽带500兆网速是多少(宽带500兆网速是指的流量吗?)

  • ipad上b站hd版区别(b站ipad改版)

    ipad上b站hd版区别(b站ipad改版)

  • qq钱包怎么找不到(qq钱包怎么找不到了)

    qq钱包怎么找不到(qq钱包怎么找不到了)

  • 苹果sos会打给谁(苹果sos会怎么样)

    苹果sos会打给谁(苹果sos会怎么样)

  • 华为媒体音量自动静音(华为媒体音量自动调节)

    华为媒体音量自动静音(华为媒体音量自动调节)

  • 苹果11一直转圈圈怎么办(苹果11一直转圈不开机也不关机)

    苹果11一直转圈圈怎么办(苹果11一直转圈不开机也不关机)

  • solopro和studio3区别(solo3pro和studio3哪个好)

    solopro和studio3区别(solo3pro和studio3哪个好)

  • 浏览器缓存的视频在哪(浏览器缓存的视频无法播放)

    浏览器缓存的视频在哪(浏览器缓存的视频无法播放)

  • 天猫精灵可以微信聊天吗(天猫精灵可以微信吗?)

    天猫精灵可以微信聊天吗(天猫精灵可以微信吗?)

  • 快手怎么删除订单记录(快手怎么删除订单了还是显示常购好物)

    快手怎么删除订单记录(快手怎么删除订单了还是显示常购好物)

  • 拼多多上面的货号在哪里(拼多多上面的货到付款怎么关闭)

    拼多多上面的货号在哪里(拼多多上面的货到付款怎么关闭)

  • 华为打电话黑屏怎么调(华为打电话黑屏感应设置怎么关闭)

    华为打电话黑屏怎么调(华为打电话黑屏感应设置怎么关闭)

  • oppo手机电子保修卡在哪里找(oppo手机电子保修卡不激活是不是代表一直保修)

    oppo手机电子保修卡在哪里找(oppo手机电子保修卡不激活是不是代表一直保修)

  • 诺基亚x6尾插怎么加固(诺基亚x6尾插永久解决方案)

    诺基亚x6尾插怎么加固(诺基亚x6尾插永久解决方案)

  • 苹果x怎么给应用加密(苹果x怎么应用分身)

    苹果x怎么给应用加密(苹果x怎么应用分身)

  • 怎么在微信发qq音乐(怎么在微信发起群接龙)

    怎么在微信发qq音乐(怎么在微信发起群接龙)

  • 手机otc怎么打开(红米手机otc怎么打开)

    手机otc怎么打开(红米手机otc怎么打开)

  • 芒果tv怎么解除手机号(芒果tv怎么解除微信绑定)

    芒果tv怎么解除手机号(芒果tv怎么解除微信绑定)

  • 手机背光坏了的表现(手机背光坏了要换屏幕吗)

    手机背光坏了的表现(手机背光坏了要换屏幕吗)

  • 惠普硒鼓怎么加粉(惠普硒鼓怎么加碳粉视频教程)

    惠普硒鼓怎么加粉(惠普硒鼓怎么加碳粉视频教程)

  • 微信小程序实现分享至朋友圈的功能(微信小程序实现支付功能)

    微信小程序实现分享至朋友圈的功能(微信小程序实现支付功能)

  • LangChain与大型语言模型(LLMs)应用基础教程:信息抽取

    LangChain与大型语言模型(LLMs)应用基础教程:信息抽取

  • 民营医院一般纳税人帐务处理视频税收风险
  • 一般纳税人报税流程详细操作
  • 盘盈的固定资产怎么做账务处理
  • 税收优惠抵扣
  • 会计中预付款余额是什么
  • 进口增值税抵扣信息委托核查函
  • 工业企业员工工资占收入比例
  • 交印花税需要身份证吗
  • 利润分配包括缴纳所得税吗
  • 商誉转销会计分录
  • 销售边角料收入属于什么收入
  • 违约金没有发票
  • 库存半成品属于什么会计科目
  • 其他应收款在什么方
  • 个人付款可以开发票吗
  • 投资款需要交印花税嘛
  • 工程承包收入如何确定
  • 企业不动产如何带抵押转让
  • 税法种类及税率
  • 交付使用资产科目核算
  • 公司还款给法人需要缴税吗
  • 即征即退收入是否计入三免三减半所得
  • 城镇土地使用税税率
  • 土地增值税通过什么科目核算
  • 印花税退款分录
  • 分配的水电费属于什么会计要素
  • win11如何设置开机自启动软件
  • 企业所得税分析方法
  • PHP:session_set_save_handler()的用法_Session函数
  • Linux系统中sort排序命令的使用教程
  • 什么是冲帐?怎么个冲法?
  • 企业租赁发票税率是多少2023年
  • findfont: Font family [‘Times New Roman‘] not found. Falling back to DejaVu Sans.
  • 免税的农业企业可以抵扣专票吗
  • 浅谈php技术
  • 会计财务报表的编制步骤
  • 固定资产进项抵扣新政策2021
  • 对公账户的银行卡号是几位数
  • 员工旅游费的税率是多少
  • 蚁群算法是什么
  • 安装充电桩电费怎么收
  • 如何根据营业执照核定税种
  • 调整以前年度亏损
  • 大型广告牌制作材料
  • 资本公积的项目有哪些
  • python PyQt5如何实现窗口功能
  • 金蝶利润表为什么只有累计数没有本月数
  • sql查看所有数据表
  • 中级会计报名必须用电脑吗
  • 专项存款可以放在什么科目
  • 非本公司员工的火车票可以报销么
  • 对于银行已入账企业未入账的未达账项应该
  • 补贴计税吗
  • 出差补贴应该怎么入账
  • 国家医疗保障机构
  • windows7怎么说
  • wmiex.exe是什么程序
  • windows怎么安装apk
  • win10 edge浏览器设置信任站点
  • linux搭建chia
  • linux开发android好处
  • cocos2dx-js
  • jquery虚拟dom
  • linux中的shell编程
  • arp绑定用户直接上网是什么意思
  • unity3d官方教程
  • linux shell脚本攻略(第3版)
  • python中如何去除空格
  • python multinomial
  • Python字符串数组
  • 死循环代码
  • android底部弹出页面
  • python flask debug
  • 云南省国家税务局
  • 重新税务登记程序有哪些
  • 福建米其林餐厅有几家
  • 税务局发票邮寄费用谁承担
  • 重庆市大学生田径锦标赛
  • 股权转让是否要交土地增值税
  • 中国古代的税收制度的演变
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设