新手问题 什么参数可以看到 Ruby 背后怎么解释运行代码

moonjourney · July 23, 2012 · Last by hhuai replied at July 24, 2012 · 2658 hits

想多理解一点 Ruby

i =0 是这么执行的 $ ruby -e 'puts RubyVM::InstructionSequence.compile(%q~i=0~).disasm' == disasm: RubyVM::InstructionSequence:compiled<@>========== local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1) [ 2] i
0000 trace 1 ( 1) 0002 putobject 0 0004 dup
0005 setlocal i 0007 leave

可以参考莫枢同学的这篇 http://prezi.com/u1xcngoh_ihe/ruby/ 友情提示,RubyVM::InstructionSequence 是 cruby 1.9 提供的支持,其它 vm 情况有所不同

#3 楼 @fsword 不错的分享,被那个跳来跳去的页面切换搞得头晕。

You need to Sign in before reply, if you don't have an account, please Sign up first.