【分享】Ruby元编程资料
acmilan2012/07/28软件综合 IP:山东
里边全是英文版,英文不好的童鞋请使用金山词霸(Windows)或StarDict星际译王(Linux)或直接搜索中文版pdf,仅供学习用途

Ruby入门:Beginning Ruby: From Novice to Professional  中文名:Ruby从入门到精通

attachment icon Beginning Ruby.pdf 7.75MB PDF 29次下载 预览

书中全部源代码:

attachment icon ruby-sources-Begining_Ruby.zip 191.58KB ZIP 36次下载

中文版传不上来,请直接搜索“Ruby从入门到精通 pdf”

Ruby元编程:Metaprogramming Ruby 中文名:Ruby元编程

attachment icon Metaprogramming Ruby.pdf 5.69MB PDF 29次下载 预览
+10  科创币    jrcsh    2012/07/28 高质量发帖
+20  科创币    .........    2012/07/28 高质量发帖
+100  科创币    phpskycn    2012/07/29 据说大神不太缺KCB。。。
来自:计算机科学 / 软件综合
11
已屏蔽 原因:{{ notice.reason }}已屏蔽
{{notice.noticeContent}}
~~空空如也
acmilan 作者
11年11个月前 IP:未同步
428609
【转】元编程简介

元编程是指某类计算机程序的编写,这类计算机程序编写或者操纵其它程序(或者自身)作为它们的数据,或者在运行时完成部分本应在编译时完成的工作。多数情况下,与手工编写全部代码相比,程序员可以获得更高的工作效率, 或者给与程序更大的灵活度去处理新的情形而无需重新编译

编写元程序的语言称之为元语言。被操纵的程序的语言称之为目标语言。一门编程语言同时也是自身的元语言的能力称之为反射或者自反

反射是促进元编程的一种很有价值的语言特性。把编程语言自身作为一级数据类型(如LISP,Forth或Rebol)也很有用。支持泛型编程的语言也使用元编程能力。

元编程通常通过两种方式实现。一种是通过应用程序编程接口(APIs)将运行时引擎的内部信息暴露于编程代码。另一种是动态执行包含编程命令的字符串表达式。因此,“程序能够编写程序”。虽然两种方式都能用于同一种语言,但大多数语言趋向于偏向其中一种。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
.........
11年11个月前 IP:未同步
428610
回 楼主(acmilan) 的帖子
这意思大概就是用程序去生成程序吧
+1
科创币
acmilan
2012-07-28
第三种才是,第12种都是反射
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
acmilan作者
11年11个月前 IP:未同步
428611
英文对照:
Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data, or that do part of the work at compile time that would otherwise be done at runtime. In some cases, this allows programmers to minimize the number of lines of code to express a solution (hence reducing development time), or it gives programs greater flexibility to efficiently handle new situations without recompilation.
The language in which the metaprogram is written is called the metalanguage. The language of the programs that are manipulated is called the object language. The ability of a programming language to be its own metalanguage is called reflection or reflexivity.
Reflection is a valuable language feature to facilitate metaprogramming. Having the programming language itself as a first-class data type (as in Lisp, Forth or Rebol) is also very useful. Generic programming invokes a metaprogramming facility within a language, in those languages supporting it.
Metaprogramming usually works in one of three ways. The first way is to expose the internals of the run-time engine to the programming code through application programming inter*aces (APIs). The second approach is dynamic execution of expressions that contain programming commands, often composed from strings, but can also be from other methods using arguments and/or context. Thus, "programs can write programs." Although both approaches can be used in the same language, most languages tend to lean toward one or the other.

第三种没有中文翻译,有谁翻译下:
The third way is to step outside the language entirely. General purpose program transformation systems, which accept language descriptions and can carry out arbitrary transformations on those languages, are direct implementations of general metaprogramming. This allows metaprogramming to be applied to virtually any target language without regard to whether that target language has any metaprogramming abilities of its own.
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
acmilan作者
11年11个月前 IP:未同步
428616
第三种就是真正的用程序生成程序。[s:274]
其实在一般语言中调用system("dir/s/b");等,还有调用SQL语句都是元编程,重要的是语言的反射特性。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
.........
11年11个月前 IP:未同步
428688
搞半天没搞懂啥叫反射.好像有点自适应的感觉.对于一个C程序员来说这个是有点挑战啊
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
acmilan作者
11年11个月前 IP:未同步
429236
反射就是程序设计语言的自我反应自我操作,以区别于SQL之类的互操作。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
phpskycn
11年11个月前 IP:未同步
429341
这个和俺经常搞的自修改代码有何区别……
+1
科创币
acmilan
2012-07-29
请问其目
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
acmilan作者
11年11个月前 IP:未同步
429370
回 7楼(phpskycn) 的帖子
这个是常规技术,而自修改代码是黑客技术,而且这个简单明了用途广。 [s:275]
而且这个是与程序设计语言相关的。。。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
phpskycn
11年11个月前 IP:未同步
429576
回 8楼(acmilan) 的帖子
前辈告诉俺:运行时修改自身的指令是一个非常不好的编程实践。。。。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
acmilan作者
11年11个月前 IP:未同步
429836
回 9楼(phpskycn) 的帖子
认真你就输了
前辈还告诉俺:没有运行时修改指令的基础,就没有运行时不能修改指令的语言[s:274]
POSIX的exec就是在运行时修改自身指令的哦。。。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论

想参与大家的讨论?现在就 登录 或者 注册

所属专业
上级专业
同级专业
acmilan
进士 学者 笔友
文章
461
回复
2934
学术分
4
2009/05/30注册,5年4个月前活动
暂无简介
主体类型:个人
所属领域:无
认证方式:邮箱
IP归属地:未同步
文件下载
加载中...
{{errorInfo}}
{{downloadWarning}}
你在 {{downloadTime}} 下载过当前文件。
文件名称:{{resource.defaultFile.name}}
下载次数:{{resource.hits}}
上传用户:{{uploader.username}}
所需积分:{{costScores}},{{holdScores}}下载当前附件免费{{description}}
积分不足,去充值
文件已丢失

当前账号的附件下载数量限制如下:
时段 个数
{{f.startingTime}}点 - {{f.endTime}}点 {{f.fileCount}}
视频暂不能访问,请登录试试
仅供内部学术交流或培训使用,请先保存到本地。本内容不代表科创观点,未经原作者同意,请勿转载。
音频暂不能访问,请登录试试
支持的图片格式:jpg, jpeg, png
插入公式
评论控制
加载中...
文号:{{pid}}
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

加载中...
详情
详情
推送到专栏从专栏移除
设为匿名取消匿名
查看作者
回复
只看作者
加入收藏取消收藏
收藏
取消收藏
折叠回复
置顶取消置顶
评学术分
鼓励
设为精选取消精选
管理提醒
编辑
通过审核
评论控制
退修或删除
历史版本
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{format('YYYY/MM/DD HH:mm:ss', toc)}}