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

  • miui12如何显示网速(miui12如何显示wifi)

    miui12如何显示网速(miui12如何显示wifi)

  • 苹果怎么关闭我的名片(苹果怎么关闭我的查找)

    苹果怎么关闭我的名片(苹果怎么关闭我的查找)

  • 隐藏相册怎么设置(隐藏相册怎么设置华为)

    隐藏相册怎么设置(隐藏相册怎么设置华为)

  • 微信新加的人能看到之前的朋友圈吗(微信新加的人能看到标签朋友圈吗)

    微信新加的人能看到之前的朋友圈吗(微信新加的人能看到标签朋友圈吗)

  • 微信群100人如何抽奖(超100人的微信群进群办法)

    微信群100人如何抽奖(超100人的微信群进群办法)

  • 拼多多月卡怎么算一个月(拼多多月卡怎么退)

    拼多多月卡怎么算一个月(拼多多月卡怎么退)

  • enter键失灵进不了系统(enter键按不动)

    enter键失灵进不了系统(enter键按不动)

  • 腾讯会议为什么打不开摄像头(腾讯会议为什么不能用蓝牙耳机)

    腾讯会议为什么打不开摄像头(腾讯会议为什么不能用蓝牙耳机)

  • 华为笔记本买i5还是i7(华为笔记本买i5还是R7)

    华为笔记本买i5还是i7(华为笔记本买i5还是R7)

  • sdm450是什么处理器(sdm460是什么处理器)

    sdm450是什么处理器(sdm460是什么处理器)

  • 什么是微聊(什么是微聊信息)

    什么是微聊(什么是微聊信息)

  • 充电器一直插在电源上可以吗(充电器一直插在插座上会坏吗)

    充电器一直插在电源上可以吗(充电器一直插在插座上会坏吗)

  • 华为nova6se有没有红外(华为nova6se有没有NFC)

    华为nova6se有没有红外(华为nova6se有没有NFC)

  • ppt能打印出来吗(ppt能打印出来吗怎么打印)

    ppt能打印出来吗(ppt能打印出来吗怎么打印)

  • 抖音开直播卖货需要什么条件(抖音开直播卖货怎么上架)

    抖音开直播卖货需要什么条件(抖音开直播卖货怎么上架)

  • iphone7p有没有nfc功能(iPhone7p有没有实况)

    iphone7p有没有nfc功能(iPhone7p有没有实况)

  • 手机投屏会产生流量吗(手机投屏会不会中毒)

    手机投屏会产生流量吗(手机投屏会不会中毒)

  • 为什么手机一直显示3g(为什么手机一直无服务)

    为什么手机一直显示3g(为什么手机一直无服务)

  • 手机怎么拍流星(手机怎么拍流星雨的照片)

    手机怎么拍流星(手机怎么拍流星雨的照片)

  • 抖音时间锁密码多少(抖音时间锁密码忘了怎么办未成年)

    抖音时间锁密码多少(抖音时间锁密码忘了怎么办未成年)

  • 花呗额度快充怎么解锁(花呗额度快充怎么搞)

    花呗额度快充怎么解锁(花呗额度快充怎么搞)

  • procreate怎么复制图形(procreate怎么复制画出来的图案)

    procreate怎么复制图形(procreate怎么复制画出来的图案)

  • airpods音质和有线的一样吗(airpods音质和有线的大小一样吗)

    airpods音质和有线的一样吗(airpods音质和有线的大小一样吗)

  • kmw_run.exe是什么进程 kmw_run进程查询(kms.exe)

    kmw_run.exe是什么进程 kmw_run进程查询(kms.exe)

  • 神经辐射场NeRF之Instant-ngp环境搭建与应用(神经辐射场nerf三维重建入门)

    神经辐射场NeRF之Instant-ngp环境搭建与应用(神经辐射场nerf三维重建入门)

  • mysql主从同步的优点

    mysql主从同步的优点

  • 缴纳个人所得税还算应届毕业生吗
  • 可税前扣除的费用有哪些
  • 自产产品用于业务招待费
  • 可明确区分的商品
  • 航空公司开具的个人抬头的发票可以税前扣除吗
  • 季度超了30万年度没超120
  • 小微企业免征的增值税要交所得税吗
  • 未开业零升报企业是否做年度汇算清缴申报
  • 土地出让要不要交印花税吗
  • 企业收到个体户开的发票
  • 境外企业提供软件使用权给境内企业
  • 只有增值税进项怎么抵扣
  • 印花税合同金额和结算金额不一致
  • 购买税控系统专用设备
  • 工程完工财务要做些什么
  • 收到境外公司服务费
  • 税收滞纳金可以税前扣除吗
  • 增值税专用发票的税率是多少啊
  • 环境保护税法是什么意思
  • 航天维护费全额抵扣
  • 非公党费返还
  • 华为手机怎么删除多余的桌面
  • 手机压缩包损坏怎么修复
  • 现金流量表的计算公式原理
  • 小规模纳税企业在应交增值税明细科目
  • 物流公司的财务能学到东西吗
  • 代发工资要缴纳社保吗
  • 个体工商户经营范围分类目录
  • 大陆公司如何开离岸账户
  • PHP:Memcached::getVersion()的用法_Memcached类
  • 员工垫付的钱会计分录
  • vscode怎么开始编程
  • 出口退税登记证在哪办
  • php中execute
  • 销售产品的运输费属于什么会计科目
  • err03 failed to
  • 详解Yii2高级版引入bootstrap.js的一个办法
  • 个税申报工资比实发工资少,但没超过5000可以举报吗
  • 大数据实时数仓
  • 大数据热点话题
  • iozone测试结果分析
  • java泛型E和T
  • 床垫可以开专票抵扣吗
  • 调整以前年度错账会计分录怎么做
  • 大气污染物排放2020标准
  • python skewness
  • 差旅费需要缴纳增值税吗
  • 哪些费用计入管理费用
  • 库存现金总分类账
  • sql server中的编程语言
  • 注册公司注册公司
  • mssqlserver怎么用
  • 销售增长率计算公式财务管理
  • 不动产出租要交什么税
  • 收到公众号消息提醒
  • 理财利息计入什么科目
  • 暂估入库一直未取得发票需要调账吗
  • 注册资本实缴制改为认缴制
  • sqlserver数据库最快存储时间
  • 修改远程桌面端口命令是什么
  • centos如何添加用户
  • 苹果mac电脑删除打印机后还显示网络错误
  • windows 10预览版
  • windowsxp忘了登录密码
  • unity特效制作教程
  • 文本框后缀
  • jQuery实现ctrl+enter(回车)提交表单
  • 疯狂冒险王官网
  • sqlserver 服务器
  • python动态创建函数
  • js移动端拖拽
  • 如何使用jquery设置一个属性值
  • js实现表格动态合并单元格
  • ready jquery
  • 类库怎么用
  • 甘肃增值税发票查验平台官网
  • 四川增值税发票查验平台
  • 不交社保申报个税有风险吗
  • 国家税务认证平台是什么
  • 深圳增值税勾选平台网址
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设